Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendCtx ¶ added in v0.99.0
AppendCtx stores slog attributes in context for the ContextHandler to extract. It copies the existing slice to avoid mutating a parent context's backing array when multiple goroutines fork from the same context.
func InitLogger ¶
Types ¶
type Config ¶
type Config struct {
// log level - debug, info, warning, error, fatal
Level string `yaml:"level" mapstructure:"level" default:"info" json:"level,omitempty"`
// format strategy - plain, json
Format string `yaml:"format" mapstructure:"format" default:"json" json:"format,omitempty"`
// audit system events - none(default), stdout, db
AuditEvents string `yaml:"audit_events" mapstructure:"audit_events" default:"none" json:"audit_events,omitempty"`
// IgnoredAuditEvents contains list of events which should be ignored in audit logs
IgnoredAuditEvents []string `yaml:"ignored_audit_events" mapstructure:"ignored_audit_events" json:"ignored_audit_events,omitempty"`
}
type ContextHandler ¶ added in v0.99.0
type ContextHandler struct {
// contains filtered or unexported fields
}
ContextHandler wraps any slog.Handler and auto-appends attributes stored in the context via AppendCtx. This enables request-scoped fields (request_id, method, etc.) to appear in every log line without passing them explicitly.
func NewContextHandler ¶ added in v0.99.0
func NewContextHandler(inner slog.Handler) *ContextHandler
Click to show internal directories.
Click to hide internal directories.