Documentation
¶
Index ¶
- func Err(err error) slog.Attr
- func ErrorCtx(ctx context.Context, err error) context.Context
- func ExtractLogAttrs(ctx context.Context) []slog.Attr
- func KV(key string, value any) slog.Attr
- func NewMockLogger() *slog.Logger
- func UpdateLogCtx(ctx context.Context, key string, value any) context.Context
- func WrapCtx(ctx context.Context, err error) error
- type MockHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Err ¶
Err creates a slog.Attr for an error Returns an empty Attr if err is nil, otherwise creates an Attr with key "error" and the error message as value
func ErrorCtx ¶
ErrorCtx extracts logging context from an error (if it was wrapped with WrapCtx) and adds it to the provided context
func ExtractLogAttrs ¶
ExtractLogAttrs extracts all logging attributes from a context Returns the attributes as a slice of slog.Attr that can be added to a log record
func KV ¶
KV creates a slog.Attr with the given key and value This is a convenience wrapper around slog.Any
func NewMockLogger ¶
func UpdateLogCtx ¶
UpdateLogCtx adds a key-value pair to the context for logging This function can be used to add structured data that will be included in all subsequent log entries using this context
Types ¶
type MockHandler ¶
type MockHandler struct{} //nolint:revive, gocritic