Documentation ¶
Index ¶
- Variables
- func ClearLogger()
- func Error(args ...interface{})
- func ErrorDepth(depth int, args ...interface{})
- func ErrorS(err error, msg string, keysAndValues ...interface{})
- func ErrorSDepth(depth int, err error, msg string, keysAndValues ...interface{})
- func Errorf(format string, args ...interface{})
- func ErrorfDepth(depth int, format string, args ...interface{})
- func Errorln(args ...interface{})
- func ErrorlnDepth(depth int, args ...interface{})
- func Fatal(args ...interface{})
- func FatalDepth(depth int, args ...interface{})
- func Fatalf(format string, args ...interface{})
- func FatalfDepth(depth int, format string, args ...interface{})
- func Fatalln(args ...interface{})
- func FatallnDepth(depth int, args ...interface{})
- func Flush()
- func FlushAndExit(flushTimeout time.Duration, exitCode int)
- func GetSeverityNames() []string
- func GlobalLogger() *logWriter
- func Info(args ...interface{})
- func InfoDepth(depth int, args ...interface{})
- func InfoS(msg string, keysAndValues ...interface{})
- func InfoSDepth(depth int, msg string, keysAndValues ...interface{})
- func Infof(format string, args ...interface{})
- func InfofDepth(depth int, format string, args ...interface{})
- func Infoln(args ...interface{})
- func InfolnDepth(depth int, args ...interface{})
- func InitGlobalLogger()
- func NewContext(ctx context.Context, logger Logger) context.Context
- func SetFile(p string)
- func SetFileMaxAgeDay(p int)
- func SetFileMaxBackups(p int)
- func SetFileMaxSizeMB(p int)
- func SetLogger(logger logr.Logger)
- func SetSeverity(s severity.Severity)
- func SetSeverityName(s string)
- func SetVerbosity(v int)
- func SwitchContextual(b bool)
- func Warning(args ...interface{})
- func WarningDepth(depth int, args ...interface{})
- func Warningf(format string, args ...interface{})
- func WarningfDepth(depth int, format string, args ...interface{})
- func Warningln(args ...interface{})
- func WarninglnDepth(depth int, args ...interface{})
- type Level
- type LogSink
- type Logger
- type RuntimeInfo
- type Verbose
- func (v Verbose) ErrorS(err error, msg string, keysAndValues ...interface{})
- func (v Verbose) Info(args ...interface{})
- func (v Verbose) InfoDepth(depth int, args ...interface{})
- func (v Verbose) InfoS(msg string, keysAndValues ...interface{})
- func (v Verbose) InfoSDepth(depth int, msg string, keysAndValues ...interface{})
- func (v Verbose) Infof(format string, args ...interface{})
- func (v Verbose) InfofDepth(depth int, format string, args ...interface{})
- func (v Verbose) Infoln(args ...interface{})
- func (v Verbose) InfolnDepth(depth int, args ...interface{})
Constants ¶
This section is empty.
Variables ¶
var ( // ExitFlushTimeout is the timeout that klog has traditionally used during // calls like Fatal or Exit when flushing log data right before exiting. // Applications that replace those calls and do not have some specific // requirements like "exit immediately" can use this value as parameter // for FlushAndExit. // // Can be set for testing purpose or to change the application's // default. ExitFlushTimeout = 10 * time.Second // OsExit is the function called by FlushAndExit to terminate the program. // // Can be set for testing purpose or to change the application's // default behavior. Note that the function should not simply return // because callers of functions like Fatal will not expect that. OsExit = os.Exit )
var ( // New is an alias for logr.New. New = logr.New )
Functions ¶
func ClearLogger ¶
func ClearLogger()
ClearLogger removes a backing Logger implementation if one was set earlier with SetLogger.
Modifying the logger is not thread-safe and should be done while no other goroutines invoke log calls, usually during program initialization.
func Error ¶
func Error(args ...interface{})
Error logs to the ERROR, WARNING, and INFO logs. Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
func ErrorDepth ¶
func ErrorDepth(depth int, args ...interface{})
ErrorDepth acts as Error but uses depth to determine which call frame to log. ErrorDepth(0, "msg") is the same as Error("msg").
func ErrorS ¶
ErrorS structured logs to the ERROR, WARNING, and INFO logs. the err argument used as "err" field of log line. The msg argument used to add constant description to the log line. The key/value pairs would be join by "=" ; a newline is always appended.
Basic examples: >> klog.ErrorS(err, "Failed to update pod status") output: >> E1025 00:15:15.525108 1 controller_utils.go:114] "Failed to update pod status" err="timeout"
func ErrorSDepth ¶
ErrorSDepth acts as ErrorS but uses depth to determine which call frame to log. ErrorSDepth(0, "msg") is the same as ErrorS("msg").
func Errorf ¶
func Errorf(format string, args ...interface{})
Errorf logs to the ERROR, WARNING, and INFO logs. Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
func ErrorfDepth ¶
ErrorfDepth acts as Errorf but uses depth to determine which call frame to log. ErrorfDepth(0, "msg", args...) is the same as Errorf("msg", args...).
func Errorln ¶
func Errorln(args ...interface{})
Errorln logs to the ERROR, WARNING, and INFO logs. Arguments are handled in the manner of fmt.Println; a newline is always appended.
func ErrorlnDepth ¶
func ErrorlnDepth(depth int, args ...interface{})
ErrorlnDepth acts as Errorln but uses depth to determine which call frame to log. ErrorlnDepth(0, "msg") is the same as Errorln("msg").
func Fatal ¶
func Fatal(args ...interface{})
Fatal logs to the FATAL, ERROR, WARNING, and INFO logs, prints stack trace(s), then calls OsExit(255).
Stderr only receives a dump of the current goroutine's stack trace. Log files, if there are any, receive a dump of the stack traces in all goroutines.
Callers who want more control over handling of fatal events may instead use a combination of different functions:
- some info or error logging function, optionally with a stack trace value generated by github.com/go-logr/lib/dbg.Backtrace
- Flush to flush pending log data
- panic, os.Exit or returning to the caller with an error
Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
func FatalDepth ¶
func FatalDepth(depth int, args ...interface{})
FatalDepth acts as Fatal but uses depth to determine which call frame to log. FatalDepth(0, "msg") is the same as Fatal("msg").
func Fatalf ¶
func Fatalf(format string, args ...interface{})
Fatalf logs to the FATAL, ERROR, WARNING, and INFO logs, including a stack trace of all running goroutines, then calls OsExit(255). Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
func FatalfDepth ¶
FatalfDepth acts as Fatalf but uses depth to determine which call frame to log. FatalfDepth(0, "msg", args...) is the same as Fatalf("msg", args...).
func Fatalln ¶
func Fatalln(args ...interface{})
Fatalln logs to the FATAL, ERROR, WARNING, and INFO logs, including a stack trace of all running goroutines, then calls OsExit(255). Arguments are handled in the manner of fmt.Println; a newline is always appended.
func FatallnDepth ¶
func FatallnDepth(depth int, args ...interface{})
FatallnDepth acts as Fatalln but uses depth to determine which call frame to log. FatallnDepth(0, "msg") is the same as Fatalln("msg").
func FlushAndExit ¶
FlushAndExit flushes log data for a certain amount of time and then calls os.Exit. Combined with some logging call it provides a replacement for traditional calls like Fatal or Exit.
func GetSeverityNames ¶
func GetSeverityNames() []string
func GlobalLogger ¶
func GlobalLogger() *logWriter
func Info ¶
func Info(args ...interface{})
Info logs to the INFO log. Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
func InfoDepth ¶
func InfoDepth(depth int, args ...interface{})
InfoDepth acts as Info but uses depth to determine which call frame to log. InfoDepth(0, "msg") is the same as Info("msg").
func InfoS ¶
func InfoS(msg string, keysAndValues ...interface{})
InfoS structured logs to the INFO log. The msg argument used to add constant description to the log line. The key/value pairs would be join by "=" ; a newline is always appended.
Basic examples: >> klog.InfoS("Pod status updated", "pod", "kubedns", "status", "ready") output: >> I1025 00:15:15.525108 1 controller_utils.go:116] "Pod status updated" pod="kubedns" status="ready"
func InfoSDepth ¶
InfoSDepth acts as InfoS but uses depth to determine which call frame to log. InfoSDepth(0, "msg") is the same as InfoS("msg").
func Infof ¶
func Infof(format string, args ...interface{})
Infof logs to the INFO log. Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
func InfofDepth ¶
InfofDepth acts as Infof but uses depth to determine which call frame to log. InfofDepth(0, "msg", args...) is the same as Infof("msg", args...).
func Infoln ¶
func Infoln(args ...interface{})
Infoln logs to the INFO log. Arguments are handled in the manner of fmt.Println; a newline is always appended.
func InfolnDepth ¶
func InfolnDepth(depth int, args ...interface{})
InfolnDepth acts as Infoln but uses depth to determine which call frame to log. InfolnDepth(0, "msg") is the same as Infoln("msg").
func InitGlobalLogger ¶
func InitGlobalLogger()
func NewContext ¶
NewContext returns logr.NewContext(ctx, logger) when contextual logging is enabled, otherwise ctx.
func SetFileMaxAgeDay ¶
func SetFileMaxAgeDay(p int)
func SetFileMaxBackups ¶
func SetFileMaxBackups(p int)
func SetFileMaxSizeMB ¶
func SetFileMaxSizeMB(p int)
func SetLogger ¶
To remove a backing logr implemention, use ClearLogger. Setting an empty logger with SetLogger(logr.Logger{}) does not work.
Modifying the logger is not thread-safe and should be done while no other goroutines invoke log calls, usually during program initialization.
func SetSeverity ¶
func SetSeverityName ¶
func SetSeverityName(s string)
func SetVerbosity ¶
func SetVerbosity(v int)
func SwitchContextual ¶
func SwitchContextual(b bool)
func Warning ¶
func Warning(args ...interface{})
Warning logs to the WARNING and INFO logs. Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
func WarningDepth ¶
func WarningDepth(depth int, args ...interface{})
WarningDepth acts as Warning but uses depth to determine which call frame to log. WarningDepth(0, "msg") is the same as Warning("msg").
func Warningf ¶
func Warningf(format string, args ...interface{})
Warningf logs to the WARNING and INFO logs. Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
func WarningfDepth ¶
WarningfDepth acts as Warningf but uses depth to determine which call frame to log. WarningfDepth(0, "msg", args...) is the same as Warningf("msg", args...).
func Warningln ¶
func Warningln(args ...interface{})
Warningln logs to the WARNING and INFO logs. Arguments are handled in the manner of fmt.Println; a newline is always appended.
func WarninglnDepth ¶
func WarninglnDepth(depth int, args ...interface{})
WarninglnDepth acts as Warningln but uses depth to determine which call frame to log. WarninglnDepth(0, "msg") is the same as Warningln("msg").
Types ¶
type Level ¶
type Level int32
Level specifies a level of verbosity for V logs. *Level implements flag.Value; the -v flag is of type Level and should be modified only through the flag.Value interface.
type Logger ¶
Logger in this package is exactly the same as logr.Logger.
func Background ¶
func Background() Logger
Background retrieves the fallback logger. It should not be called before that logger was initialized by the program and not by code that should better receive a logger via its parameters. TODO can be used as a temporary solution for such code.
func FromContext ¶
FromContext retrieves a logger set by the caller or, if not set, falls back to the program's global logger (a Logger instance or xlog itself).
func LoggerWithName ¶
LoggerWithName returns logger.WithName(name) when contextual logging is enabled, otherwise the logger.
func LoggerWithValues ¶
LoggerWithValues returns logger.WithValues(...kv) when contextual logging is enabled, otherwise the logger.
type RuntimeInfo ¶
type RuntimeInfo = logr.RuntimeInfo
Runtimeinfo in this package is exactly the same as logr.RuntimeInfo.
type Verbose ¶
type Verbose struct {
// contains filtered or unexported fields
}
Verbose is a boolean type that implements Infof (like Printf) etc. See the documentation of V for more information.
func (Verbose) ErrorS ¶
ErrorS is equivalent to the global Error function, guarded by the value of v. See the documentation of V for usage.
func (Verbose) Info ¶
func (v Verbose) Info(args ...interface{})
Info is equivalent to the global Info function, guarded by the value of v. See the documentation of V for usage.
func (Verbose) InfoDepth ¶
InfoDepth is equivalent to the global InfoDepth function, guarded by the value of v. See the documentation of V for usage.
func (Verbose) InfoS ¶
InfoS is equivalent to the global InfoS function, guarded by the value of v. See the documentation of V for usage.
func (Verbose) InfoSDepth ¶
InfoSDepth is equivalent to the global InfoSDepth function, guarded by the value of v. See the documentation of V for usage.
func (Verbose) Infof ¶
Infof is equivalent to the global Infof function, guarded by the value of v. See the documentation of V for usage.
func (Verbose) InfofDepth ¶
InfofDepth is equivalent to the global InfofDepth function, guarded by the value of v. See the documentation of V for usage.
func (Verbose) Infoln ¶
func (v Verbose) Infoln(args ...interface{})
Infoln is equivalent to the global Infoln function, guarded by the value of v. See the documentation of V for usage.
func (Verbose) InfolnDepth ¶
InfolnDepth is equivalent to the global InfolnDepth function, guarded by the value of v. See the documentation of V for usage.