Skip to content

Expand logging #51

Description

@446564

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 sloginfo 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)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or requestp2-mediumMedium priority

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions