logging

package
v1.1.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorLevel = Level(logrus.ErrorLevel)
	InfoLevel  = Level(logrus.InfoLevel)
	DebugLevel = Level(logrus.DebugLevel)
	TraceLevel = Level(logrus.TraceLevel)
)

Variables

This section is empty.

Functions

func ContextWithLogger

func ContextWithLogger(ctx context.Context, logger *Logger) context.Context

ContextWithLogger returns a context.Context that has been augmented with the provided *Logger.

Types

type Level added in v0.7.0

type Level uint32

type Logger added in v0.7.0

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

Logger is a wrapper around logr.Logger that provides a more ergonomic API. This is heavily inspired by a similar wrapper from https://github.com/kubernetes-sigs/cluster-api-provider-aws

func LoggerFromContext

func LoggerFromContext(ctx context.Context) *Logger

LoggerFromContext extracts a *Logger from the provided context.Context and returns it. If no *Logger is found, a global *Logger is returned.

func NewLogger added in v0.7.0

func NewLogger(level Level) *Logger

NewLogger returns a new *Logger with the provided log level.

func Wrap added in v0.7.0

func Wrap(logrLogger logr.Logger) *Logger

Wrap returns a new *Logger that wraps the provided logr.Logger.

func (*Logger) Debug added in v0.7.0

func (l *Logger) Debug(msg string, keysAndValues ...any)

Debug logs a message at the debug level.

func (*Logger) Error added in v0.7.0

func (l *Logger) Error(err error, msg string, keysAndValues ...any)

Error logs a message at the error level.

func (*Logger) GetLogger added in v0.7.0

func (l *Logger) GetLogger() logr.Logger

GetLogger returns the underlying logr.Logger for cases where one needs to interact with the logr API directly.

func (*Logger) Info added in v0.7.0

func (l *Logger) Info(msg string, keysAndValues ...any)

Info logs a message at the info level.

func (*Logger) Trace added in v0.7.0

func (l *Logger) Trace(msg string, keysAndValues ...any)

Trace logs a message at the trace level.

func (*Logger) WithValues added in v0.7.0

func (l *Logger) WithValues(keysAndValues ...any) *Logger

WithValues adds key-value pairs to a logger's context.

Jump to

Keyboard shortcuts

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