Documentation
¶
Overview ¶
Package log contains utility functions around Go slog package
Index ¶
- func Error(err error) slog.Attr
- func FromContext(ctx context.Context) *slog.Logger
- func NewJSONTraceIDHandler(w io.Writer, opts *slog.HandlerOptions) slog.Handler
- func NewTextTraceIDHandler(w io.Writer, opts *slog.HandlerOptions) slog.Handler
- func WithLogger(ctx context.Context, logger *slog.Logger) context.Context
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FromContext ¶
FromContext retrieves logger from the given context. If no logger is associated with the given context it will return value from slog.Default.
func NewJSONTraceIDHandler ¶
NewJSONTraceIDHandler creates new slog.JSONHandler which adds a `TraceID` attribute to all loggings if trace id is present.
func NewTextTraceIDHandler ¶ added in v0.28.2
NewTextTraceIDHandler creates new slog.TextHandler which adds a `TraceID` attribute to all loggings if trace id is present.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.