Repository navigation
Closed
Labels
enhancementNew feature or request
Description
Summary
The server has no structured logging. A sweep of server/src finds 166 console.* calls across 22 files, with no logger library (no pino/winston/bunyan), no log levels, no correlation/request IDs, and no JSON output. Everything is a flat string written at a single implicit level.
Why it matters
- No log levels — verbosity can't be tuned per environment; debug-grade chatter ships to production logs unconditionally, inflating cost and hurting signal-to-noise.
- No correlation/request ID — the tracking pipeline spans many
awaitsteps, but there's no way to tie one request's log lines together. This is the most painful gap when debugging a single failing run in the cloud. - No JSON format — log aggregators (Vercel/Datadog/etc.) can't parse or filter flat strings; you can't query by
level,requestId, route, or status. - Unconditional per-request IP/origin logging —
server/src/server.js:40logsmethod / path / origin / ipon every request. That's both noise and a mild PII concern; with levels it would belong atdebug.
Suggested approach (phased — not one giant PR)
Phase 1 — core (this issue, or its first PR):
- Add a small
server/src/lib/logger.jswrapping a structured logger. pino is the natural fit for ESM Node — fast, JSON by default, levels built in. - Add a request-ID middleware that attaches a correlation id (
req.id) and exposes a per-request child logger. - Convert the per-request access log at
server.js:40to the structured logger and move it todebuglevel (so it's off by default in production). - Pick the level from an env var, e.g.
LOG_LEVEL(defaultinfoin prod,debuglocally), and document it inserver/.env.example.
Phase 2 — migration (follow-up PRs):
- Replace the remaining
console.*calls withlogger.*at appropriate levels, file by file. The manual smoke scripts undersrc/(see chore(server): move or remove the manual smoke scripts under src/ #240) can keepconsole.*since they're operator-facing.
Scope note
This is a cross-cutting infrastructure change touching ~22 files, so it is not a good-first-issue — Phase 1 is a focused, reviewable PR; Phase 2 should land incrementally rather than as a single 166-call rewrite.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Activity
Pallavikumarimdb commentedon Jun 15, 2026
@gkhngyk Can I work on this issue?
gkhngyk commentedon Jun 16, 2026
Hi @Pallavikumarimdb, thanks for your interest! I've assigned this issue to you. Feel free to reach out if you have any questions. Happy coding!
gkhngyk commentedon Jun 26, 2026
Phase 1 is complete — the core structured-logging infrastructure shipped in #273 (thanks @Pallavikumarimdb 🙏):
server/src/lib/logger.js— pino with configurableLOG_LEVEL+ sensitive-header redactionserver/src/middleware/request-id.js— per-requestreq.idcorrelation ID +req.logchild loggerserver.js(per-request access log moved todebug, CORS/socket/startup routed through the logger)Since this issue's title is "introduce structured logging" and that infrastructure now exists, I'm closing it as completed.
Phase 2 (migrating the remaining ~123
console.*calls across 23 files to the logger) is tracked in a dedicated, file-by-file issue: #303. @Pallavikumarimdb — you're very welcome to continue there if you'd like to keep going.chore(server): structured logging Phase 2 — routes slice (req.log) (#334
chore(server): structured logging Phase 2 — workers slice (#335)
chore(server): structured logging Phase 2 — lib job manager/runner (#336
chore(server): structured logging Phase 2 — server.js + middleware (#337
chore(server): structured logging Phase 2 — cloro-scraper (final slic…