Skip to content

feat(log): json/logfmt/text output with request-scoped labels - #21

Open
kylecrawshaw wants to merge 1 commit into
mainfrom
feat/log-config
Open

kylecrawshaw wants to merge 1 commit into
mainfrom
feat/log-config

Conversation

@kylecrawshaw

@kylecrawshaw kylecrawshaw commented Sep 1, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Add a [log] config section (level, format, optional labels) plus ANTEROOM_LOG_LEVEL / ANTEROOM_LOG_FORMAT overrides. Default stays text at info; -v still forces debug.
  • Encode the same slog records as json, logfmt, or text with no new dependencies.
  • Attach request_id (honoring inbound X-Request-ID / X-Correlation-ID, otherwise generated) and W3C traceparent trace_id/span_id through context on request-path log lines, and forward X-Request-ID upstream so application logs join.

Test plan

  • go test -race ./... (unit coverage for config, handlers, request-ID forwarding, and hit-line context)
  • Start with default config: stderr is slog text at info, no per-request hits
  • anteroom -v still logs one hit line per request, now including request_id
  • [log] format = "json" (or ANTEROOM_LOG_FORMAT=json) produces JSON; logfmt uses ts= and lowercase level
  • Send X-Request-ID: keep-me and a W3C traceparent; logs carry those ids and the upstream sees X-Request-ID: keep-me
  • [log.labels] service = "anteroom" appears on every line, including startup

…abels

Operators can pick a collector-friendly encoding from [log], and request-path
lines carry request_id (and W3C traceparent ids) without repeating those
fields at each call site.

Co-authored-by: Cursor <cursoragent@cursor.com>
@kylecrawshaw
kylecrawshaw marked this pull request as ready for review September 1, 2026 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant