Documentation
¶
Overview ¶
Package log provides slog-based structured logging for paper-board services.
Phase 1.0: minimal JSONHandler. Redaction rules + OTel correlation Phase 1.5.
Index ¶
- func New(w io.Writer, service string, level slog.Level) *slog.Logger
- func Pkg(ctx context.Context) *slog.Logger
- func SetDefault(l *slog.Logger)
- func WithOrg(ctx context.Context, id string) context.Context
- func WithRequestID(ctx context.Context, id string) context.Context
- func WithTraceID(ctx context.Context, id string) context.Context
- func WithUser(ctx context.Context, id string) context.Context
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New returns a slog.Logger writing structured JSON to w. If w is nil, os.Stderr is used. Pass service name for the "service" attribute.
func Pkg ¶
Pkg returns a logger pre-loaded with context attributes (request_id, trace_id, org_id, user_id). Use this everywhere instead of slog.Default() directly so auto-fields are included.
log.Pkg(ctx).Info("user created", "id", u.ID)
func SetDefault ¶
SetDefault installs `l` as the package default. Once called, slog.Default() returns this logger across the process.
func WithRequestID ¶
WithRequestID stores request_id in ctx for downstream Pkg() calls.
func WithTraceID ¶
WithTraceID stores W3C trace ID.
Types ¶
This section is empty.