logger

package
v1.52.2 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2022 License: Apache-2.0, BSD-2-Clause, MIT, + 1 more Imports: 7 Imported by: 139

Documentation

Index

Constants

View Source
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"
)
View Source
const IDFieldName = "process_id"

IDFieldName is the name of the id field for a logger.

Variables

View Source
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

func MustNewZapLogger(level string, format string, additionalOpts ...logzap.Opts) logr.Logger

MustNewZapLogger is like NewZapLogger but panics on invalid input.

func NewIDLogger added in v1.14.0

func NewIDLogger(logger logr.Logger) logr.Logger

NewIDLogger extends an existing logger with a randomly generated id field (key `process_id`).

func NewZapLogger added in v1.29.0

func NewZapLogger(level string, format string, additionalOpts ...logzap.Opts) (logr.Logger, error)

NewZapLogger creates a new logr.Logger backed by Zap.

func ZapLogger added in v1.35.0

func ZapLogger(development bool) logr.Logger

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.

Jump to

Keyboard shortcuts

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