Repository navigation
chore(server): structured logging Phase 2 — lib job manager/runner - #336
Merged
Merged
Conversation
Migrate the console.* calls in lib/job-manager.js and lib/job-runner.js
to the module-level pino logger. Both run outside the request lifecycle,
so they use the module logger with structured fields.
- job-manager.js (10): DB update failures → logger.error({ err, jobId });
cleanup summaries → logger.info({ count })
- job-runner.js (6): job failures → logger.error({ err, jobId });
cancellations + retry-scheduling → logger.info
({ jobId, delayMs, attempt, attempts })
Part of #303 (Phase 2 of #245). lib/cloro-scraper.js is intentionally
left out of this slice to avoid churn with the query fan-out work (#332);
server.js + middleware follow separately.
There was a problem hiding this comment.
Pull request overview
This PR is an incremental “structured logging Phase 2” slice that replaces console.* usage in background job orchestration (job-manager / job-runner) with the shared module-level pino logger (server/src/lib/logger.js), keeping behavior the same while producing leveled, structured JSON logs.
Changes:
- Replace
console.errorinjob-manager.jswithlogger.error({ err, jobId }, ...)for Supabase update/delete failures. - Replace
console.loginjob-manager.jscleanup paths withlogger.info({ count }, ...). - Replace
console.*injob-runner.jswith structuredlogger.info/logger.errorfor cancellations, failures, and retry scheduling (includingdelayMs/ attempt metadata).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| server/src/lib/job-runner.js | Migrates job cancellation/failure/retry console logging to structured pino logger with job metadata fields. |
| server/src/lib/job-manager.js | Migrates Supabase error logs and cleanup summary logs from console to structured pino logger. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
Fourth incremental slice of #303 (structured logging Phase 2). Migrates the
console.*calls inlib/job-manager.jsandlib/job-runner.jsto the module-level pinologger. Both run outside the request lifecycle, so they use the modulelogger(notreq.log) with structured fields instead of interpolated strings.Files migrated (~16 calls):
job-manager.js(10): DB update failures →logger.error({ err, jobId }, …); cleanup summaries →logger.info({ count }, …)job-runner.js(6): job failures →logger.error({ err, jobId }, …); cancellations + retry-scheduling →logger.info({ jobId, delayMs, attempt, attempts }, …)Level mapping per the issue (
console.error→error,console.log→info). Behaviour unchanged.Related issue
Part of #303 (Phase 2 of #245), following #330, the routes slice, and the workers slice.
lib/cloro-scraper.jsis intentionally left out of this slice to avoid churn/conflicts with the query fan-out work (#332).server.js+middleware/index.jsfollow as the final slice.Type of change
chore— MaintenanceHow to test
server/:npm run lint,npm run format:check,npm run test(93 tests) all pass.grep -n "console\." server/src/lib/job-manager.js server/src/lib/job-runner.jsreturns nothing.errorfor failures,infofor cancellation + retry scheduling withdelayMs/attempt) instead of aconsole.*string.Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdnpm run lintpasses (fromserver/)npm run format:checkpasses (fromserver/)