Repository navigation
chore(server): structured logging Phase 2 — workers slice - #335
Merged
Merged
Conversation
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.
There was a problem hiding this comment.
Pull request overview
This PR continues the structured logging Phase 2 migration by replacing console.* usage in background workers with the module-level pino logger (server/src/lib/logger.js), emitting leveled JSON logs with structured fields. This aligns worker logging with the broader server logging approach while avoiding request-scoped req.log (not available in workers).
Changes:
- Migrate ~20+
console.*calls intracking-worker.jstologger.debug/info/warn/errorwith structured metadata. - Migrate the final
console.logincontent-worker.jstologger.infowith{ brandId, generated }. - Remove logging of customer prompt text from worker log lines (favoring identifiers/metadata instead).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| server/src/workers/tracking-worker.js | Replaces console.* with structured pino logging across task submission, polling, milestones, and error paths. |
| server/src/workers/content-worker.js | Converts generation summary line to structured logger.info. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+160
to
163
| logger.error( | ||
| { err: sub.reason, scraperId: failedTask.scraperId }, | ||
| 'failed to submit scraper task', | ||
| ); |
Comment on lines
+261
to
264
| logger.warn( | ||
| { brandId, pending, expected: expectedSubmitted }, | ||
| 'cloro delivery stalled — some tasks never returned; continuing', | ||
| ); |
Comment on lines
+274
to
277
| logger.info( | ||
| { submitted: submitted.length, total: scraperTasks.length }, | ||
| 'tasks submitted, polling for results', | ||
| ); |
|
|
||
| if (modelTasks.length > 0) { | ||
| console.log(`[tracking] Running ${modelTasks.length} AI model tasks concurrently...`); | ||
| logger.info({ count: modelTasks.length }, 'running ai model tasks concurrently'); |
| `[tracking] Failed prompt "${prompt.text.slice(0, 50)}..." model=${modelName} region=${region}:`, | ||
| err.message, | ||
| ); | ||
| logger.error({ err, model: modelName, region }, 'ai model task failed'); |
6 tasks done
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
Third incremental slice of #303 (structured logging Phase 2), following #330 (lib/config) and the routes slice. Migrates the
console.*calls inserver/src/workers/to the module-level pinologger.Workers run outside the request lifecycle, so there is no
req.log— they use the moduleloggerwith structured fields instead of interpolated strings.Files migrated (~21 calls):
tracking-worker.js(20):Polling task=…,Submitted …,result saved) →logger.debug({ taskId, scraperId })Submitting N scraper tasks,N results stored) →logger.info({ brandId, count, … })logger.error({ err, … }); poll/stall retries →logger.warntaskId/scraperId/model/regionidentify the work instead.content-worker.js(1): generation summary →logger.info({ brandId, generated })Level mapping follows the issue (
console.log→info/debugby operational value,warn→warn,error→error). Behaviour is unchanged.Related issue
Part of #303 (Phase 2 of #245). Remaining
lib/(job-manager,job-runner,cloro-scraper) andserver.js/middlewarefollow as separate PRs.Type of change
chore— MaintenanceHow to test
server/:npm run lint,npm run format:check,npm run test(93 tests) all pass.grep -rn "console\." server/src/workers/returns nothing.console.*strings, with no customer prompt text in the log body.Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdnpm run lintpasses (fromserver/)npm run format:checkpasses (fromserver/)