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 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{})
- func WithName(name string) logr.Logger
- func WithValues(kvList ...interface{}) logr.Logger
- 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 logs a warning messages with the given message format with format specifier and arguments.
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 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
func Warning ¶
func Warning(msg string, kvs ...interface{})
Warning logs a warning messages with the given key/value pairs as context.
func Warningf ¶
func Warningf(format string, args ...interface{})
Warningf logs a warning messages with the given message format with format specifier and arguments.
func WithValues ¶
WithValues adds some key-value pairs of context to a logger.
Types ¶
type LoggerImpl ¶
type LoggerImpl interface { logr.Logger // 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) CloneWithLevel(level int) LoggerImpl }
LoggerImpl represents the ability to log messages, both errors and not.
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) // 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