log

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 3, 2026 License: MIT Imports: 4 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(w io.Writer, service string, level slog.Level) *slog.Logger

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

func Pkg(ctx context.Context) *slog.Logger

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

func SetDefault(l *slog.Logger)

SetDefault installs `l` as the package default. Once called, slog.Default() returns this logger across the process.

func WithOrg

func WithOrg(ctx context.Context, id string) context.Context

WithOrg stores org_id (tenant context).

func WithRequestID

func WithRequestID(ctx context.Context, id string) context.Context

WithRequestID stores request_id in ctx for downstream Pkg() calls.

func WithTraceID

func WithTraceID(ctx context.Context, id string) context.Context

WithTraceID stores W3C trace ID.

func WithUser

func WithUser(ctx context.Context, id string) context.Context

WithUser stores user_id.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL