Beacon currently uses the standard log.Printf throughout for all output with no way to filter verbosity or change output format. This makes it difficult to run quietly in production or debug specific subsystems without log noise.
Goals
- Configurable log level (debug, info, warn, error) via config or env var
- Structured logging with consistent fields (broker name, component, etc.) for easier log aggregation
- Minimal disruption to existing log call sites — ideally a drop-in migration path
Considerations
log/slog (stdlib, Go 1.21+) is the natural fit given the Go version — no additional dependency
- Text handler for human-readable output in development, JSON handler for production
- Log level should be settable via env var (e.g.
LOG_LEVEL=debug) and optionally config.yaml
- Output format (text/json) could also be configurable
- The ingest path is the noisiest — broker name is already included in most log lines but would benefit from being a structured field
- The cache layer currently has no logging at all — debug-level cache hit/miss logging would be useful here
Scope
- Add
LogConfig to internal/config/config.go (level, format)
- Initialize a global
slog.Logger in main.go and pass or set as default
- Migrate existing
log.Printf call sites to slog — info for normal operation, warn for degraded states, error for failures
- Add debug-level cache hit/miss logging to
internal/cache
Out of scope
- Log rotation or file output (use a reverse proxy or systemd for that)
- Per-subsystem log levels (can be revisited if needed)
Beacon currently uses the standard
log.Printfthroughout for all output with no way to filter verbosity or change output format. This makes it difficult to run quietly in production or debug specific subsystems without log noise.Goals
Considerations
log/slog(stdlib, Go 1.21+) is the natural fit given the Go version — no additional dependencyLOG_LEVEL=debug) and optionallyconfig.yamlScope
LogConfigtointernal/config/config.go(level,format)slog.Loggerinmain.goand pass or set as defaultlog.Printfcall sites toslog—infofor normal operation,warnfor degraded states,errorfor failuresinternal/cacheOut of scope