Documentation
¶
Overview ¶
Package log provides structured logging utilities.
Package log provides structured logging utilities.
Index ¶
- func Base() zerolog.Logger
- func Configure(cfg Config)
- func ContextWithJobID(ctx context.Context, id string) context.Context
- func ContextWithRequestID(ctx context.Context, id string) context.Context
- func Derive(build func(*zerolog.Context)) zerolog.Logger
- func FromContext(ctx context.Context) *zerolog.Logger
- func JobIDFromContext(ctx context.Context) string
- func L() *zerolog.Logger
- func Middleware() func(http.Handler) http.Handler
- func RequestIDFromContext(ctx context.Context) string
- func WithComponent(component string) zerolog.Logger
- func WithComponentFromContext(ctx context.Context, component string) zerolog.Logger
- func WithContext(ctx context.Context, logger zerolog.Logger) zerolog.Logger
- type Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextWithJobID ¶
ContextWithJobID stores the provided job ID in the context.
func ContextWithRequestID ¶
ContextWithRequestID stores the provided request ID in the context.
func Derive ¶
Derive attaches arbitrary fields to a child logger using the provided builder function.
func FromContext ¶
FromContext returns a logger from the context, or a new one if not present.
func JobIDFromContext ¶
JobIDFromContext extracts the job ID from context if present.
func Middleware ¶
Middleware returns a new http.Handler middleware that logs requests using zerolog.
func RequestIDFromContext ¶
RequestIDFromContext extracts the request ID from context if present.
func WithComponent ¶
WithComponent returns a child logger annotated with the given component name.
func WithComponentFromContext ¶
WithComponentFromContext returns a logger that is annotated with the component name and enriched with correlation fields from ctx.