Repository navigation
chore(server): structured logging Phase 2 — cloro-scraper (final slice, closes #303) - #351
Merged
Merged
Conversation
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).
There was a problem hiding this comment.
Pull request overview
Completes structured logging Phase 2 for the server by migrating the remaining console.* calls in server/src/lib/cloro-scraper.js to the module-level pino logger, using leveled, structured JSON logs and avoiding logging customer prompt text in the submit “start” line.
Changes:
- Replaced
console.log/errorwithlogger.info/debug/errorin Cloro task submit + poll paths. - Converted interpolated log strings into structured fields (
taskId,scraperId,taskType,pollCount, etc.). - Removed prompt text from the submit “submitting task” log line (keeps identifying fields only).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
283
to
285
| if (res.status === 404) { | ||
| console.error(`[cloro] Poll #${pollCount} task=${taskId}: 404 not found`); | ||
| logger.error({ taskId, pollCount }, 'cloro poll: task not found (404)'); | ||
| throw new Error(`Cloro task ${taskId} not found`); |
Comment on lines
287
to
289
| const errorBody = await res.text().catch(() => ''); | ||
| console.error(`[cloro] Poll #${pollCount} task=${taskId}: HTTP ${res.status}`); | ||
| logger.error({ taskId, pollCount, status: res.status }, 'cloro poll: http error'); | ||
| throw new Error(`Cloro poll error ${res.status}: ${errorBody.slice(0, 300)}`); |
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
The final slice of #303 (structured logging Phase 2). Migrates the last remaining
console.*calls — the 10 inlib/cloro-scraper.js— to the module-levelpinologger. This file was intentionally held back from the earlier slices to avoid churn/conflicts with the query fan-out work (#341), which is now merged.After this, every non-script
console.*inserver/srcroutes through the structured logger.Changes (
server/src/lib/cloro-scraper.js)Runs outside the request lifecycle, so it uses the module
logger(notreq.log), with structured fields instead of interpolated strings:task submitted,completed,polling) →logger.debug({ taskId, scraperId, pollCount, … })submitting scraper task) →logger.info({ taskType, scraperId, region })logger.error({ scraperId/taskId, status/reason, … })taskType/scraperId/regionidentify the task instead.Level mapping per the issue. Behaviour unchanged; lines are now leveled + JSON.
Related issue
Closes #303. Phase 2 of #245 is complete across: #330 (lib/config), #334 (routes), #335 (workers), #336 (lib job manager/runner), #337 (server.js + middleware), and this final slice.
Type of change
chore— MaintenanceHow to test
server/:npm run lint,npm run format:check,npm run test(99 tests) all pass.grep -rn "console\." server/src --include="*.js" | grep -v /scripts/ | grep -v .test.jsreturns nothing.Checklist
feature/,fix/,chore/,docs/) — see CONTRIBUTING.mdnpm run lintpasses (fromserver/)npm run format:checkpasses (fromserver/)