Repository navigation
chore(server): structured logging Phase 2 — lib/config module-level logger (part 1) - #330
Merged
Merged
Conversation
…ogger (part 1) First incremental slice of #303: migrate the console.* calls in the single-owner lib/ and config files to the module-level pino logger, with structured fields instead of interpolated strings. - lib/audit/{retry,recommendations,llm-signals}.js - lib/{opportunity-generator,cloro-result-handler,shopping-cards,openai-tracker}.js - config/supabase.js (startup fatal -> logger.fatal before exit) No request-scoped lines here (that's the routes/middleware slices); these all use the module logger. Behavior unchanged; logs are now leveled + JSON.
This was referenced Jul 3, 2026
gkhngyk
added a commit
that referenced
this pull request
Jul 3, 2026
) * chore(server): structured logging Phase 2 — routes slice (req.log) Migrate the console.* calls in server/src/routes/ to the structured logger. All lines run inside request handlers, so they use the request-scoped req.log child (carries requestId) instead of raw console.error, with { err } structured fields. - audits.js — 6 handlers → req.log; 2 detached background functions (runAuditJob / createAndRunAudit) use the module logger + auditId/brandId - content.js, prompts.js, tracking.js, volumes.js, traffic.js, competitors.js, topics.js — handler console.error → req.log.error({ err }) Part of #303 (Phase 2 of #245), part 2 of the incremental sweep after #330. Level mapping unchanged (error → error); lines are now leveled + JSON + request-correlatable. * fix(server): use module logger in traffic route, not req.log trafficRoutes is mounted before requestIdMiddleware in server.js (it needs its own open CORS for navigator.sendBeacon from any origin), so req.log is undefined on this public beacon path — req.log.error would throw on the first error. Use the module-level logger instead. Addresses the Copilot review on #334.
gkhngyk
added a commit
that referenced
this pull request
Jul 4, 2026
Migrate the console.* calls in server/src/workers/ to the module-level
pino logger. Workers run outside the request lifecycle, so they use the
module logger (not req.log), with structured fields instead of
interpolated strings.
- tracking-worker.js (20): per-task progress chatter → logger.debug
({ taskId, scraperId }); operational milestones → logger.info
({ brandId, count, … }); failures → logger.error({ err, … });
poll/stall retries → logger.warn. Customer prompt text is no longer
written to logs — task/scraper ids identify the work instead.
- content-worker.js (1): generation summary → logger.info
({ brandId, generated })
Part of #303 (Phase 2 of #245), part 3 after #330 (lib/config) and the
routes slice. Level mapping per the issue; behaviour unchanged.
This was referenced Jul 6, 2026
Merged
gkhngyk
added a commit
that referenced
this pull request
Jul 6, 2026
…e) (#351) Migrate the last console.* calls (lib/cloro-scraper.js) to the module-level pino logger. This file was deliberately held back from the earlier slices to avoid churn with the query fan-out work (#341, now merged). - submit/poll per-task chatter (task submitted, completed, polling) → logger.debug({ taskId, scraperId, ... }); operational start → logger.info ({ taskType, scraperId, region }); failures/timeouts → logger.error ({ ..., status/reason }). Customer prompt text is no longer written to the submit log — taskType/scraperId/region identify the task instead. Closes #303: every non-script console.* in server/src now routes through the structured logger. Phase 2 of #245 is complete (parts: #330, #334, #335, #336, #337, and this).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
First incremental slice of #303 (structured logging Phase 2). Migrates the
console.*calls in the single-ownerlib/andconfigfiles to the module-level pinologgerfromlib/logger.js, using structured fields instead of interpolated strings.None of these run inside request handlers, so they all use the module
logger(thereq.logrequest-scoped lines belong to the routes / middleware slices, which will follow as separate PRs per the issue's "do it incrementally" guidance).Files migrated (~10 calls):
lib/audit/retry.js— retry warning →logger.warn({ label, attempt, attempts, delayMs, err }, …)lib/audit/recommendations.js,lib/audit/llm-signals.js— failure →logger.error({ err, model }, …)lib/opportunity-generator.js— 2×console.log→logger.info({ brandId, … }, …)lib/cloro-result-handler.js— 2×console.error→logger.error({ err, … }, …)lib/shopping-cards.js,lib/openai-tracker.js—console.error→logger.error({ err, … }, …)config/supabase.js— missing-env startup fatal →logger.fatal(…)beforeprocess.exit(1)Level mapping follows the issue:
console.error→error,console.warn→warn,console.log→info. Behaviour is unchanged — lines are now leveled + JSON-formatted.Related issue
Part of #303 (Phase 2 of #245). This is part 1; routes (
req.log), workers, andserver.js/middlewareremain for follow-up PRs.Type of change
chore— MaintenanceHow to test
yarn lint/yarn testfromserver/pass (93 tests).grep -Rn "console\." server/src/lib/audit server/src/lib/opportunity-generator.js server/src/lib/cloro-result-handler.js server/src/lib/shopping-cards.js server/src/lib/openai-tracker.js server/src/config/supabase.jsreturns nothing.console.*string.Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.md