Skip to content

🧹 [code health] Refactor console.log hygiene#90

Merged
mbayue merged 3 commits into
masterfrom
jules-11759176283803621038-d0634b37
Jul 5, 2026
Merged

🧹 [code health] Refactor console.log hygiene#90
mbayue merged 3 commits into
masterfrom
jules-11759176283803621038-d0634b37

Conversation

@mbayue

@mbayue mbayue commented Jul 5, 2026

Copy link
Copy Markdown
Owner

🎯 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 logInfo helper to standardize info logs in dev and prod. Logs now emit JSON with level, message, timestamp, and optional meta for easier parsing and alignment with logApi/logError.

  • Refactors
    • Added logInfo in server/utils/logger.ts (supports optional meta).
    • Updated server/dev-api.ts and server/prod-server.ts to use logInfo for startup and GitHub token status messages.
    • Extended server/utils/logger.test.ts to cover logInfo, including meta fields and timestamp.

Written for commit 15d827b. Summary will update on new commits.

Review in cubic

Co-authored-by: mbayue <70324722+mbayue@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 4 files

Confidence score: 3/5

  • In server/utils/logger.ts, spreading ...meta after level, message, and timestamp lets 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)
Loading

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread server/utils/logger.ts
mbayue and others added 2 commits July 5, 2026 09:49
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>
@mbayue mbayue merged commit 7c77a7a into master Jul 5, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant