log

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DebugLevel logs are typically voluminous, and are usually disabled in production.
	DebugLevel = Level(zapcore.DebugLevel)
	// InfoLevel is the default logging priority.
	InfoLevel = Level(zapcore.InfoLevel)
	// WarnLevel logs are more important than Info, but don't need individual human review.
	WarnLevel = Level(zapcore.WarnLevel)
	// ErrorLevel logs are high-priority. If an application is running smoothly,
	// it shouldn't generate any error-level logs.
	ErrorLevel = Level(zapcore.ErrorLevel)
	// DPanicLevel logs are particularly important errors. In development the
	// logger panics after writing the message.
	DPanicLevel = Level(zapcore.DPanicLevel)
	// PanicLevel logs a message, then panics.
	PanicLevel = Level(zapcore.PanicLevel)
	// FatalLevel logs a message, then calls os.Exit(1).
	FatalLevel = Level(zapcore.FatalLevel)
)

Variables

View Source
var (
	// Log is the base logger
	Log logr.Logger = logr.New(ctrllog.NullLogSink{})
)

Functions

func NewLogger

func NewLogger(opts ...Opts) logr.Logger

NewLogger creates new Logger based on controller runtime zap logger

func SetLevel

func SetLevel(level Level) func(o *Options)

SetLevel sets Options.LogLevel, which configures the the minimum enabled logging level e.g Debug, Info.

func SetLogger

func SetLogger(logger logr.Logger)

SetLogger sets a concrete logging implementation for all deferred Loggers. Being top level application and not a library or dependency, let's delegation logger used by any dependency

func SetMode

func SetMode(mode Mode) func(o *Options)

SetMode sets Options.LogMode, which configures to use (or not use) development mode

Types

type Level

type Level zapcore.Level

Level configures the verbosity of the logging.

func ToLevel

func ToLevel(level string) Level

ToLevel converts a string to a log level.

type Mode

type Mode int8

Mode defines the log output mode.

const (
	// ModeProd is the log mode for production.
	ModeProd Mode = iota
	// ModeDev is for more human-readable outputs, extra stack traces
	// and logging info. (aka Zap's "development config".)
	// https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg/log/zap#UseDevMode
	ModeDev
)

func ToMode

func ToMode(mode string) Mode

ToMode converts a string to a log mode. Use either 'production' for `LogModeProd` or 'development' for `LogModeDev`.

type Options

type Options struct {
	// LogLevel configures the verbosity of the logging.
	LogLevel Level
	// LogMode defines the log output mode.
	LogMode Mode
	// DestWriter controls the destination of the log output.  Defaults to
	// os.Stderr.
	DestWriter io.Writer
}

Options contains all possible settings.

type Opts

type Opts func(*Options)

Opts allows to manipulate Options.

func WriteTo

func WriteTo(out io.Writer) Opts

WriteTo configures the logger to write to the given io.Writer, instead of standard error. See Options.DestWriter.

Jump to

Keyboard shortcuts

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