Documentation
¶
Overview ¶
Package log provides utilities for attaching an slog.Logger configured with request-specific attributes to context.Context. The logger can later be retrieved or used indirectly through package-level logging function calls.
Server and client extension point implementations should use this package for generating logs instead of using other loggers or slog directly.
Index ¶
- func Error(ctx context.Context, msg string, err error, keyValArgs ...any)
- func Info(ctx context.Context, msg string, keyValArgs ...any)
- func Log(ctx context.Context, level slog.Level, msg string, keyValArgs ...any)
- func LoggerFrom(ctx context.Context) *slog.Logger
- func Warn(ctx context.Context, msg string, keyValArgs ...any)
- func WithLogger(ctx context.Context, logger *slog.Logger) context.Context
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Error ¶
Error invokes ErrorContext on the slog.Logger associated with the provided Context or slog.Default() if no context-scoped logger is available.
func Info ¶
Info invokes InfoContext on the slog.Logger associated with the provided Context or slog.Default() if no context-scoped logger is available.
func Log ¶
Log invokes Log on the slog.Logger associated with the provided Context or slog.Default() if no context-scoped logger is available.
func LoggerFrom ¶
LoggerFrom returns the Logger associated with the context, or slog.Default() if no context-scoped logger is available.
func Warn ¶
Warn invokes WarnContext on the slog.Logger associated with the provided Context or slog.Default() if no context-scoped logger is available.
Types ¶
This section is empty.