util

package
v2.11.24 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 15, 2021 License: Apache-2.0 Imports: 13 Imported by: 1

Documentation

Overview

Package util provides ancillary functionality to go-vcloud-director library logging.go regulates logging for the whole library. See LOGGING.md for detailed usage

Index

Constants

View Source
const TmpDirPrefix = "govcd"

Variables

View Source
var (
	// All go-vcloud director logging goes through this logger
	Logger *log.Logger

	// Name of the log file
	// activated by GOVCD_LOG_FILE
	ApiLogFileName string = "go-vcloud-director.log"

	// Globally enabling logs
	// activated by GOVCD_LOG
	EnableLogging bool = false

	// OverwriteLog specifies if log file should be overwritten on every run
	OverwriteLog bool = false

	// Enable logging of passwords
	// activated by GOVCD_LOG_PASSWORDS
	LogPasswords bool = false

	// Enable logging of Http requests
	// disabled by GOVCD_LOG_SKIP_HTTP_REQ
	LogHttpRequest bool = true

	// Enable logging of Http responses
	// disabled by GOVCD_LOG_SKIP_HTTP_RESP
	LogHttpResponse bool = true

	// Sends log to screen. If value is either "stderr" or "err"
	// logging will go to os.Stderr. For any other value it will
	// go to os.Stdout
	LogOnScreen string = ""

	// PanicEmptyUserAgent will panic if Request header does not have HTTP User-Agent set This
	// is generally useful in tests and is off by default.
	PanicEmptyUserAgent bool = false
)

Functions

func CallFuncName

func CallFuncName() string

Returns the name of the function that called the current function. Used by functions that call processResponseOutput and processRequestOutput

func CurrentFuncName

func CurrentFuncName() string

Returns the name of the current function

func FuncNameCallStack

func FuncNameCallStack() string

Returns a string containing up to 10 function names from the call stack

func GetFileContentType

func GetFileContentType(file string) (string, error)

GetFileContentType returns the real file type

func InitLogging

func InitLogging()

Initializes default logging values

func ProcessRequestOutput

func ProcessRequestOutput(caller, operation, url, payload string, req *http.Request)

Logs the essentials of a HTTP request

func ProcessResponseOutput

func ProcessResponseOutput(caller string, resp *http.Response, result string)

Logs the essentials of a HTTP response

func SanitizedHeader

func SanitizedHeader(inputHeader http.Header) http.Header

SanitizedHeader returns a http.Header with sensitive fields masked

func SetApiLogFunctions

func SetApiLogFunctions(functions string)

Sets the list of functions to include

func SetCustomLogger

func SetCustomLogger(customLogger *log.Logger)

func SetLog

func SetLog()

initializes logging with known parameters

func SetSkipTags

func SetSkipTags(tags string)

Sets the list of tags to skip

func TogglePanicEmptyUserAgent

func TogglePanicEmptyUserAgent(willPanic bool)

TogglePanicEmptyUserAgent allows to enable Panic in test if HTTP User-Agent is missing. This generally is useful in tests and is off by default.

func Unpack

func Unpack(tarFile string) ([]string, string, error)

Extract files to system tmp dir with name govcd+random number. Created folder with files isn't deleted. Returns extracted files paths in array and path where folder with files created.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL