Documentation
¶
Overview ¶
Package logger provides the process-wide zerolog singleton.
File output uses core/logger/rotate.Writer (date + size rotation, direct O_APPEND writes, no userspace buffer). Msglog shares the same writer type via msgbus.MsgLogger.
Logging discipline (P2-3) ¶
The plaintext msglog (core/msgbus.MsgLogger, JSONL) is the SOLE per-event record. Zerolog text logging exists for lifecycle transitions (startup, connect, disconnect, shutdown) and cold error paths only. The rules:
- No log statement above Debug on hot paths: the dispatch loop, ring-buffer and arena operations (core/mem, core/msgbus Allocate/Publish/Dispatch/Send), and per-message adapter parse paths (dataclient processMessage and everything it calls).
- High-frequency conditions — event drops, overflow waits, unrouted commands — are recorded as atomic counters at the point of occurrence and surfaced by a low-frequency observer goroutine (msgbus.StartObserver, 1 s cadence), never logged inline.
- Fatal/Panic are permitted anywhere: they terminate the process, so they cannot recur at event rate.
- Debug is permitted on hot paths for diagnostics, because zerolog short-circuits disabled levels without allocating; production runs at Info or above. Do not compute log arguments outside the zerolog call chain (no fmt.Sprintf, no Interface() of live structs).
These rules are enforced statically by internal/lint (TestHotPathLogging), which rejects Info/Warn/Error calls in the designated hot-path functions and any logger import in core/mem.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Log = consoleLogger
Log is kept for backward compatibility; defaults to console logger. Deprecated: Use Get() for the singleton logger.
Functions ¶
Types ¶
type Config ¶
type Config struct {
Level string `yaml:"level"`
Stdout *bool `yaml:"stdout"` // nil defaults to true
File rotate.FileConfig `yaml:"file"` // empty Dir = no file output
}
Config contains logger configuration.
type Options ¶
type Options struct {
Level string // Log level: trace, debug, info, warn, error, fatal, panic
Stdout bool // Write human-readable logs to stdout (default true via Config)
File rotate.FileConfig // File output; empty Dir disables file logging
}
Options contains configuration options for the logger.