Documentation ¶
Index ¶
- func Cause(ctx context.Context) error
- func SetDefaultLogger(l logr.Logger)
- type CancelCauseFunc
- type CancelFunc
- type Context
- func AddLogger(parent context.Context) Context
- func Background() Context
- func TODO() Context
- func WithCancel(parent Context) (Context, context.CancelFunc)
- func WithCancelCause(parent Context) (Context, context.CancelCauseFunc)
- func WithDeadline(parent Context, d time.Time) (Context, context.CancelFunc)
- func WithDeadlineCause(parent Context, d time.Time, cause error) (Context, context.CancelFunc)
- func WithLogger(parent context.Context, logger logr.Logger) Context
- func WithTimeout(parent Context, timeout time.Duration) (Context, context.CancelFunc)
- func WithTimeoutCause(parent Context, timeout time.Duration, cause error) (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 CancelCauseFunc ¶ added in v3.54.2
type CancelCauseFunc = context.CancelCauseFunc
type CancelFunc ¶
type CancelFunc = context.CancelFunc
CancelFunc and CancelCauseFunc are type aliases to allow use as if they are the same types as the standard library variants.
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 WithCancelCause ¶ added in v3.54.2
func WithCancelCause(parent Context) (Context, context.CancelCauseFunc)
WithCancelCause returns context.WithCancelCause 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 WithDeadlineCause ¶ added in v3.54.2
WithDeadlineCause returns context.WithDeadlineCause 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 WithTimeoutCause ¶ added in v3.54.2
func WithTimeoutCause(parent Context, timeout time.Duration, cause error) (Context, context.CancelFunc)
WithTimeoutCause returns context.WithTimeoutCause 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).