Documentation ¶
Index ¶
- func SetDefaultLogger(l logr.Logger)
- type CancelFunc
- type Context
- func AddLogger(parent context.Context) Context
- func Background() Context
- func TODO() Context
- func WithCancel(parent Context) (Context, context.CancelFunc)
- func WithDeadline(parent Context, d time.Time) (Context, context.CancelFunc)
- func WithLogger(parent context.Context, logger logr.Logger) Context
- func WithTimeout(parent Context, timeout time.Duration) (Context, context.CancelFunc)
- func WithValue(parent Context, key, val any) Context
- func WithValues(parent Context, keyAndVals ...any) Context
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetDefaultLogger ¶
SetupDefaultLogger sets the package-level global default logger that will be used for Background and TODO contexts. On startup, the default logger will be configured to output logs to stderr. Use logr.Discard() to disable all logs from Contexts.
Types ¶
type CancelFunc ¶
type CancelFunc = context.CancelFunc
CancelFunc is a type alias to context.CancelFunc to allow use as if they are the same types.
type Context ¶
Context wraps context.Context and includes an additional Logger() method.
func AddLogger ¶
AddLogger converts a context.Context into a Context. If the underlying type is already a Context, that will be returned, otherwise a default logger will be added.
func Background ¶
func Background() Context
Background returns context.Background with a default logger.
func WithCancel ¶
func WithCancel(parent Context) (Context, context.CancelFunc)
WithCancel returns context.WithCancel with the log object propagated.
func WithDeadline ¶
WithDeadline returns context.WithDeadline with the log object propagated and the deadline added to the structured log values.
func WithLogger ¶
WithLogger converts a context.Context into a Context by adding a logger.
func WithTimeout ¶
WithTimeout returns context.WithTimeout with the log object propagated and the timeout added to the structured log values.
func WithValue ¶
WithValue returns context.WithValue with the log object propagated and the value added to the structured log values (if the key is a string).
func WithValues ¶
WithValues returns context.WithValue with the log object propagated and the values added to the structured log values (if the key is a string).