log

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2024 License: Apache-2.0 Imports: 3 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Print int = iota
	Debug
	Info
	Warning
	Error
	Critical
)

Variables

View Source
var (
	Log = logr.New(dlog)
)

Log is the base logger used by kubebuilder. It delegates to another logr.Logger. You *must* call SetLogger to get any actual logging. If SetLogger is not called within the first 30 seconds of a binaries lifetime, it will get set to a nullLogging.

Functions

func FromContext

func FromContext(ctx context.Context, keysAndValues ...interface{}) logr.Logger

FromContext returns a logger with predefined values from a context.Context.

func IntoContext

func IntoContext(ctx context.Context, log logr.Logger) context.Context

IntoContext takes a context and sets the logger as one of its values. Use FromContext function to retrieve the logger.

func SetLogger

func SetLogger(l logr.Logger)

SetLogger sets a concrete logging implementation for all deferred Loggers.

Types

type DelegatingLogSink

type DelegatingLogSink struct {
	// contains filtered or unexported fields
}

DelegatingLogSink is a logsink that delegates to another logr.LogSink. If the underlying promise is not nil, it registers calls to sub-loggers with the logging factory to be populated later, and returns a new delegating logger. It expects to have *some* logr.Logger set at all times (generally a no-op logger before the promises are fulfilled).

func NewDelegatingLogSink

func NewDelegatingLogSink(initial logr.LogSink) *DelegatingLogSink

NewDelegatingLogSink constructs a new DelegatingLogSink which uses the given logger before its promise is fulfilled.

func (*DelegatingLogSink) Enabled

func (l *DelegatingLogSink) Enabled(level int) bool

Enabled tests whether this Logger is enabled. For example, commandline flags might be used to set the logging verbosity and disable some info logs.

func (*DelegatingLogSink) Error

func (l *DelegatingLogSink) Error(err error, msg string, keysAndValues ...interface{})

Error logs an error, with the given message and key/value pairs as context. It functions similarly to calling Info with the "error" named value, but may have unique behavior, and should be preferred for logging errors (see the package documentations for more information).

The msg field should be used to add context to any underlying error, while the err field should be used to attach the actual error that triggered this log line, if present.

func (*DelegatingLogSink) Fulfill

func (l *DelegatingLogSink) Fulfill(actual logr.LogSink)

Fulfill switches the logger over to use the actual logger provided, instead of the temporary initial one, if this method has not been previously called.

func (*DelegatingLogSink) Info

func (l *DelegatingLogSink) Info(level int, msg string, keysAndValues ...interface{})

Info logs a non-error message with the given key/value pairs as context.

The msg argument should be used to add some constant description to the log line. The key/value pairs can then be used to add additional variable information. The key/value pairs should alternate string keys and arbitrary values.

func (*DelegatingLogSink) Init

func (l *DelegatingLogSink) Init(info logr.RuntimeInfo)

Init implements logr.LogSink.

func (*DelegatingLogSink) WithName

func (l *DelegatingLogSink) WithName(name string) logr.LogSink

WithName provides a new Logger with the name appended.

func (*DelegatingLogSink) WithValues

func (l *DelegatingLogSink) WithValues(tags ...interface{}) logr.LogSink

WithValues provides a new Logger with the tags appended.

Jump to

Keyboard shortcuts

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