logctx

package
v0.5.7 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddBytes added in v0.5.2

func AddBytes(ctx zerolog.Context, key string, value []byte, maxSize uint32) zerolog.Context

AddBytes adds the key/value (truncated by maxSize) to the log context.

func AddBytesToContext added in v0.5.2

func AddBytesToContext(ctx context.Context, key string, value []byte, maxSize uint32)

AddBytesToContext adds the key/value to the log context.

func AddMapToContext

func AddMapToContext(ctx context.Context, fields map[string]any)

AddMapToContext adds the map of key/values to the log context.

func AddStrToContext

func AddStrToContext(ctx context.Context, key, value string)

AddStrToContext adds the key/value to the log context.

func AddToContext

func AddToContext(ctx context.Context, key string, value any)

AddToContext adds the key/value to the log context.

func GetID

func GetID(ctx context.Context) string

GetID returns the request ID logged to the context, otherwise 0.

func NewContextFrom

func NewContextFrom(ctx context.Context) context.Context

NewContextFrom returns a child context without cancel and a sub-logger attached. If no logger is associated with the given ctx as the parent logger DefaultContextLogger is used if not nil, otherwise a disabled logger is used.

func NewSubLoggerContext

func NewSubLoggerContext(ctx context.Context, log zerolog.Logger) context.Context

NewSubLoggerContext creates a new logger with an empty context.

func SetID

func SetID(ctx context.Context, id string) context.Context

SetID sets the request ID logged to the context.

Types

type ContextKey

type ContextKey string

Jump to

Keyboard shortcuts

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