Skip to content

Add a opt-in mechanism to make the node output logs in JSON format #332

Description

@kaisoz

Add a opt-in mechanism to make the node output logs in JSON format (GOLOG_LOG_FMT=json / cfg.Format) instead of the console encoder.

Points to weigh:

  • Machine consumers of the debug command get whole-line JSON, no console-format parsing needed. journalctl / terminal readability suffers; operators would need jq or GOLOG_LOG_FMT=color to read logs comfortably.
  • Middle ground worth exploring: per-sink encoders - JSON for the ringbuffer:// sink (what tools consume), console for stderr (what humans read). go-log configures one format globally, so this needs a custom zap core wiring in main.go.

Activity

  1. added this to the Next milestone on Sep 14, 2026
  2. added theissue type on Sep 14, 2026
  3. saurav-shakya commented on Oct 17, 2026

    @saurav-shakya
    Contributor

    Hi @kaisoz @aojea, I'd like to work on what's left of this one.

    It looks like the opt-in part is already done: --log-format text|json landed on main in #688 and it's in the reference docs. What's still open is the middle ground from the description. Right now --log-format json switches stderr and the ring buffer behind /debug/logs at the same time, so you can't have readable terminal output and machine-friendly debug logs together.

    I've put together a small change that keeps --log-format for stderr (and the --daemonize log file) and always writes the ring buffer as JSON. That way anything reading agentmesh-node debug logs never has to parse the console format. It hooks the ring in with go-log's NewPipeReader(PipeFormat(JSONOutput)), so there's no custom zap core and no new dependency. The code is in #737.

    There are two things I'd like your opinion on:

    1. Should /debug/logs be JSON by default, or should the ring just follow --log-format? The first option changes what debug logs prints today when you're on the default text format.
    2. The ring is fed through a pipe, so a line shows up there a moment after the log call returns. Because of that, I changed the existing ring test to wait for RecentLogs. If you'd rather keep it synchronous, I can switch to a SetPrimaryCore tee instead, but that means rebuilding go-log's output handling.

    Happy to rework it either way.

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

    No labels
    No labels

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions