Documentation
¶
Overview ¶
Package logging configures log/slog for the process.
Index ¶
- func New(w io.Writer, level, format string) *slog.Logger
- func ParseLevel(s string) slog.Level
- func SetCaller(ctx context.Context, caller string)
- func SetWorkspace(ctx context.Context, slug string)
- func WithJob(ctx context.Context, job string) context.Context
- func WithRequest(ctx context.Context, requestID string, route func() string) context.Context
- type ContextHandler
- type Fields
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New returns a logger writing to w in the given format ("json" or "text") at the given level ("debug", "info", "warn", "error").
func ParseLevel ¶
ParseLevel maps a level name to a slog.Level, defaulting to info.
func SetCaller ¶
SetCaller names who makes a request: "user:<id>", "key:<id>" or "agent:<id>". Never a name or an email.
func SetWorkspace ¶
SetWorkspace names the workspace a request acts in (its slug).
Types ¶
type ContextHandler ¶
ContextHandler adds the context's request or job fields to each record.
type Fields ¶
type Fields struct {
// contains filtered or unexported fields
}
Fields are what a request's log lines say about it. They are filled in as the request goes through the stack, so they are read under a lock.
func FieldsFrom ¶
FieldsFrom returns the fields of ctx's request or job, or nil.