Documentation ¶
Overview ¶
Package log provides logging functionalities
Index ¶
- func Error(err error, msg string, kvs ...interface{})
- func Fatal(err error, msg string, kvs ...interface{})
- func ForceWriteToStdErr(msg []byte)
- func GetLogr() logr.Logger
- func Info(msg string, kvs ...interface{})
- func Infof(format string, args ...interface{})
- func Outputf(format string, args ...interface{})
- func QuietMode(quiet bool)
- func SendProgressUpdate(status, currentPhase string, totalPhases []string)
- func SetAuditLog(fileName string)
- func SetChannel(channel chan<- []byte)
- func SetFile(fileName string)
- func SetVerbosity(verbosity int32)
- func UnsetStdoutStderr()
- func Warning(msg string, kvs ...interface{})
- func Warningf(format string, args ...interface{})
- type LoggerImpl
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Fatal ¶
Fatal logs a fatal message with the given key/value pairs as context and returns with os.Exit(255)
func GetLogr ¶
GetLogr returns logr logger object that can be used to attach to some external logr logger
func Info ¶
func Info(msg string, kvs ...interface{})
Info logs a non-error message with the given key/value pairs as context.
func Infof ¶
func Infof(format string, args ...interface{})
Infof logs a non-error message with the given key/value pairs as context.
func QuietMode ¶
func QuietMode(quiet bool)
QuietMode sets the logging mode to quiet If this mode is set, writer will not write anything to stderr
func SendProgressUpdate ¶
SendProgressUpdate sends the progress to the listening logChannel
func SetAuditLog ¶
func SetAuditLog(fileName string)
SetAuditLog sets the log file that should capture all logging activity. This file will contain all logging regardless of set verbosity level.
func SetChannel ¶
func SetChannel(channel chan<- []byte)
SetChannel sets the channel to writer if channel is set, writer will forward log messages to this log channel
func SetFile ¶
func SetFile(fileName string)
SetFile sets the logFile to writer if the non-empty file name is used, writer will also write the logs to this file
func SetVerbosity ¶
func SetVerbosity(verbosity int32)
SetVerbosity sets verbosity level and also updates default verbosity level
func UnsetStdoutStderr ¶
func UnsetStdoutStderr()
UnsetStdoutStderr intercept the actual stdout and stderr this will ensure no other external library prints to stdout/stderr and use actual stdout/stderr through tkg writer only Note: Should not use this functions for normal cli commands like
tkg get regions, tkg set regions
As it will stop any libraries like table.pretty to print on stdout
Types ¶
type LoggerImpl ¶
type LoggerImpl interface { // Enabled tests whether this Logger is enabled. For example, commandline // flags might be used to set the logging verbosity and disable some info // logs. Enabled() bool // Info logs a non-error message with the given key/value pairs as context. // // The msg argument should be used to add some constant description to // the log line. The key/value pairs can then be used to add additional // variable information. The key/value pairs should alternate string // keys and arbitrary values. Info(msg string, keysAndValues ...interface{}) // Error logs an error, with the given message and key/value pairs as context. // It functions similarly to calling Info with the "error" named value, but may // have unique behavior, and should be preferred for logging errors (see the // package documentations for more information). // // The msg field should be used to add context to any underlying error, // while the err field should be used to attach the actual error that // triggered this log line, if present. Error(err error, msg string, keysAndValues ...interface{}) // V returns an Logger value for a specific verbosity level, relative to // this Logger. In other words, V values are additive. V higher verbosity // level means a log message is less important. It's illegal to pass a log // level less than zero. V(level int) LoggerImpl // WithValues adds some key-value pairs of context to a logger. // See Info for documentation on how key/value pairs work. WithValues(keysAndValues ...interface{}) LoggerImpl // WithName adds a new element to the logger's name. // Successive calls with WithName continue to append // suffixes to the logger's name. It's strongly recommended // that name segments contain only letters, digits, and hyphens // (see the package documentation for more information). WithName(name string) LoggerImpl // Infof logs a non-error messages with the given message format with format specifier and arguments. Infof(format string, args ...interface{}) // Warning logs a warning messages with the given key/value pairs as context. Warning(msg string, kvs ...interface{}) // Warningf logs a warning messages with the given message format with format specifier and arguments. Warningf(format string, args ...interface{}) // Fatal logs a fatal message with the given key/value pairs as context and returns with os.Exit(1) Fatal(err error, msg string, kvs ...interface{}) // Print logs a message of generic type Print(msg string, err error, logType string, kvs ...interface{}) // Output writes a message to stdout Outputf(msg string, kvs ...interface{}) // SetThreshold implements a New Option that allows to set the threshold level for a logger. // The logger will write only log messages with a level/V(x) equal or higher to the threshold. SetThreshold(threshold *int32) // Clone creates cloned copy of the logger Clone() LoggerImpl // CloneWithLevel creates cloned copy of the logger with updated log level CloneWithLevel(level int) LoggerImpl // WithCallDepth implements a New Option that allows to set the callDepth level for a logger. WithCallDepth(callDepth int) LoggerImpl }
LoggerImpl represents the ability to log messages, both errors and not.
func WithName ¶
func WithName(name string) LoggerImpl
WithName adds a new element to the logger's name.
func WithValues ¶
func WithValues(kvList ...interface{}) LoggerImpl
WithValues adds some key-value pairs of context to a logger.
type Writer ¶
type Writer interface { // Write writes message to stdout/stderr, logfile and sends to the channel if channel is set // // header is message header to append as a message prefix // msg is actual message to write // logEnabled is used to decide whether to write this message to stdout/stderr or not // logVerbosity is used to decide which message to write for different output types // logType used to decide should write to stdout or stderr Write(header []byte, msg []byte, logEnabled bool, logVerbosity int32, logType string) (n int, err error) // SetFile sets the logFile to writer // if the non-empty file name is used, writer will also // write the logs to this file SetFile(fileName string) // SetAuditLog sets the log file that should capture all logging activity. This // file will contain all logging regardless of set verbosity level. SetAuditLog(fileName string) // SetChannel sets the channel to writer // if channel is set, writer will forward log messages to this log channel SetChannel(channel chan<- []byte) // QuietMode sets the logging mode to quiet // If this mode is set, writer will not write anything to stderr QuietMode(quiet bool) // SetVerbosity sets verbosity level and also updates default verbosity level SetVerbosity(verbosity int32) // SendProgressUpdate sends the progress to the listening logChannel SendProgressUpdate(status string, step string, totalSteps []string) }
Writer defines methods to write and configure tkg writer