-
Notifications
You must be signed in to change notification settings - Fork 1
Add file-based logging system for mcp-gateway CLI/server logs with daily rotation #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Implement package-level logging to enable debugging without interfering with the TUI. Logs are written to ~/.mcp-gateway/logs/ as JSON lines with daily rotation and automatic cleanup. Changes: - Add logger module (src/logger.ts) with debug/info/warn/error levels - Daily log rotation: one file per day (gateway-YYYY-MM-DD.log) - Automatic cleanup of logs older than 30 days - Initialize logger in run.ts and server/index.ts for all entry points - Replace console.warn/error calls with logger throughout codebase - Remove console.log statements from TUI effects (won't display anyway) - Keep user-facing console output (help, version, startup messages) Log entries include ISO 8601 timestamp, level, message, and optional context object for structured debugging in production.
@codex review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. This made me look at our biome/linting setup and i think it's currently not working correctly.
We should configure biome to give warnings when console..logs are used:
// In the biome.jsonc we should expand the suspicious section to warn about it
"suspicious": { "noExplicitAny": "error", "noConsole": "warn" },
And i don't think we're running the right biome commands either, the script section of the package json should be updated to complain a bit more during linting and do a bit of linting during formatting.
I was also wondering why we'd roll our own file based logging solution but the logger in this PR is still fairly straightforward (and configuring other loggers can be a bit of a pain)
- "lint": "biome check --write .",
- "format": "biome format --write .",
+ "lint": "biome ci .",
+ "format": "biome check --write .",
i'll tackle the biome improvements! |
Implement package-level logging to enable debugging without interfering with the TUI. Logs are written to ~/.mcp-gateway/logs/ as JSON lines with daily rotation and automatic cleanup.
Changes:
Log entries include ISO 8601 timestamp, level, message, and optional context object for structured debugging in production.
Note
Add structured file-based logging (JSONL, daily rotation, 30‑day cleanup) and replace console usage across server/CLI, proxy, capture, and tools.
src/logger.ts
withdebug/info/warn/error
, JSONL output, daily file rotation (gateway-YYYY-MM-DD.log
), and 30‑day cleanup.LOG_LEVEL
env; no-throw, test-aware behavior.src/run.ts
andsrc/server/index.ts
; add Hono logger middleware inserver/create-server.ts
.dev:server
script; print essential user messages only.console.*
withlogger
incapture.ts
,mcp-server.ts
,mcp-tools/capture-tools.ts
, andserver/create-proxy-routes.ts
with structured context.appendCapture
(includefilePath
), SSE capture paths, and MCP middleware/handler.console.log
messages intui/effects.ts
; keep UI-driven feedback.suspicious.noConsole=warn
; adjust workspace scripts tobiome ci
/biome check --write
.tests/logger.test.ts
; annotate existing tests to ignore console linting.Written by Cursor Bugbot for commit 20670d7. This will update automatically on new commits. Configure here.