Documentation ¶
Index ¶
- Constants
- Variables
- func MustNewZapLogger(level string, format string, additionalOpts ...logzap.Opts) logr.Logger
- func NewIDLogger(logger logr.Logger) logr.Logger
- func NewZapLogger(level string, format string, additionalOpts ...logzap.Opts) (logr.Logger, error)
- func ZapLogger(development bool) logr.Logger
Constants ¶
const ( // DebugLevel is the debug log level, i.e. the most verbose. DebugLevel = "debug" // InfoLevel is the default log level. InfoLevel = "info" // ErrorLevel is a log level where only errors are logged. ErrorLevel = "error" // FormatJSON is the output type that produces a JSON object per log line. FormatJSON = "json" // FormatText outputs the log as human-readable text. FormatText = "text" )
const IDFieldName = "process_id"
IDFieldName is the name of the id field for a logger.
Variables ¶
var ( // AllLogLevels is a slice of all available log levels. AllLogLevels = []string{DebugLevel, InfoLevel, ErrorLevel} // AllLogFormats is a slice of all available log formats. AllLogFormats = []string{FormatJSON, FormatText} )
Functions ¶
func MustNewZapLogger ¶ added in v1.35.0
MustNewZapLogger is like NewZapLogger but panics on invalid input.
func NewIDLogger ¶ added in v1.14.0
NewIDLogger extends an existing logger with a randomly generated id field (key `process_id`).
func NewZapLogger ¶ added in v1.29.0
NewZapLogger creates a new logr.Logger backed by Zap.
func ZapLogger ¶ added in v1.35.0
ZapLogger is a Logger implementation. If development is true, a Zap development config will be used (stacktraces on warnings, no sampling), otherwise a Zap production config will be used (stacktraces on errors, sampling). Additionally, the time encoding is adjusted to `zapcore.ISO8601TimeEncoder`. This is used by extensions for historical reasons. TODO: consolidate this with NewZapLogger and make everything configurable in a harmonized way
Types ¶
This section is empty.