🧹 [code health] Refactor console.log hygiene#90
Conversation
Co-authored-by: mbayue <70324722+mbayue@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
There was a problem hiding this comment.
1 issue found across 4 files
Confidence score: 3/5
- In
server/utils/logger.ts, spreading...metaafterlevel,message, andtimestamplets caller-provided metadata overwrite those core fields, which can corrupt log structure and make alerting/debugging unreliable after merge — prevent overrides by reordering/whitelisting fields (or filtering reserved keys) before merging.
Architecture diagram
sequenceDiagram
participant DevAPI as Dev API (server/dev-api.ts)
participant ProdSrv as Prod Server (server/prod-server.ts)
participant Logger as Logger (server/utils/logger.ts)
participant Console as stdout
Note over DevAPI,ProdSrv: Server startup logging flow
alt Dev server startup
DevAPI->>Logger: NEW: logInfo("GitHub API: ...")
end
alt Prod server startup
ProdSrv->>Logger: NEW: logInfo("listening on http://...")
ProdSrv->>Logger: NEW: logInfo("GitHub API: ...")
end
Logger->>Logger: Format JSON: { level: "info", message, timestamp, ...meta }
Logger->>Console: console.log(jsonString)
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
Co-authored-by: mbayue <70324722+mbayue@users.noreply.github.com>
🎯 What: Replaced direct `console.log` calls with a structured `logInfo` function. Added `logInfo` to `server/utils/logger.ts` and updated `server/dev-api.ts` and `server/prod-server.ts` to use it.
💡 Why: Improves log readability and standardization by ensuring informational logs follow the same JSON structure (`{ level, message, timestamp }`) as existing `logApi` and `logError` functions, which facilitates log parsing in production and unifies dev and prod output formats.
✅ Verification: Ran `bun test` specifically over `server/utils/logger.test.ts` and passed successfully. Also ran the full test suite which passed the unrelated integration failures appropriately.
✨ Result: Cleaner, more consistent JSON logging without unstructured raw text cluttering stdout.
PR created automatically by Jules for task 11759176283803621038 started by @mbayue
Summary by cubic
Replaced direct console.log calls with a structured
logInfohelper to standardize info logs in dev and prod. Logs now emit JSON with level, message, timestamp, and optional meta for easier parsing and alignment withlogApi/logError.logInfoinserver/utils/logger.ts(supports optional meta).server/dev-api.tsandserver/prod-server.tsto uselogInfofor startup and GitHub token status messages.server/utils/logger.test.tsto coverlogInfo, including meta fields and timestamp.Written for commit 15d827b. Summary will update on new commits.