Skip to content

Wide-event NDJSON logging (loggingsucks.com) - #14

Open
SteveParson wants to merge 2 commits into
mainfrom
cursor/wide-event-logging-6d2a
Open

SteveParson wants to merge 2 commits into
mainfrom
cursor/wide-event-logging-6d2a

Conversation

@SteveParson

Copy link
Copy Markdown
Owner

Summary

Implements lessons from loggingsucks.com: stop diary-style log_info("…") strings; emit one structured wide event per unit of work as NDJSON on stderr.

This branch is stacked on the KISS cleanups from #13 (includes that commit). Merging this can supersede #13, or merge #13 first — either works.

What changed

  • New src/log.c + rewritten src/log.h: log_event / log_event_new / log_format_event / log_emit
  • Units of work: session.start|end, gateway.hello|ready|reconnect|heartbeat|…, message.handle, tls.*
  • High-cardinality fields: request_id, channel_id, message_id, sequence
  • Business context on matches: matched_king, reply/reaction HTTP statuses, content_len (not message text)
  • Envelope on every line: timestamp, service, version, pid, optional commit
  • Levels: info + error only; tail-sample non-error/non-match via LOG_SAMPLE_RATE
  • Never logs DISCORD_TOKEN
  • Docs: README, AGENTS, .env.sample

Example

{"timestamp":"2026-11-03T22:50:00Z","service":"king","version":"0.1","pid":123,"event":"message.handle","outcome":"success","duration_ms":48,"request_id":"req_…","channel_id":"222","message_id":"111","matched_king":true,"reply_http_status":200,"reaction_http_status":204,"content_len":10}

Verification

make docker-test   # 98 passed
make docker-lint
Open in Web Open in Cursor 

cursoragent and others added 2 commits November 3, 2026 22:41
Name Discord/WebSocket opcodes, DRY JSON int parsing and logging,
extract heartbeat/token/dispatch helpers, and drop dead TLS state —
keeping the small module layout and readability.

Co-authored-by: me <me@steveparson.ca>
Apply loggingsucks.com lessons: one structured JSON event per unit of
work, high-cardinality Discord IDs, business context on matches, env
fields on every line, info/error only, and tail sampling via
LOG_SAMPLE_RATE. Never log the bot token.

Co-authored-by: me <me@steveparson.ca>
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.

2 participants