chore(logger): consolidate console.* behind a leveled logger#48
Conversation
The kernel had 48 raw console.log/error/warn calls scattered across src/core, src/index.ts, and src/providers/discord. Most bypassed the existing core/logger module entirely, so logs went to stdout but never hit logs/errors.log, were not gated by level, and were inconsistently formatted (some with [bridge] prefix, some with [discord/cmd], some plain). Extend core/logger.ts with debug/info/warn methods + a LOG_LEVEL config knob (default 'info'). Extend the KernelLogger interface in core/types.ts to match. The error method keeps its file-write behaviour and now also respects the level gate (it always writes the file regardless of console level). Route console.* through the logger in: - src/index.ts orchestrator lifecycle - src/core/api.ts server start/error - src/core/maestro.ts CLI spawn/parse failures - src/core/transcription.ts missing-dep warnings - src/core/attachments.ts mkdir/download warnings - src/core/providers.ts unknown-provider warning - src/providers/discord/adapter.ts ready/autocomplete/command errors - src/providers/discord/messageCreate.ts mention detection, thread-create, transcription error paths - Discord's messageCreate.debug calls are now gated: by default (LOG_LEVEL=info) the per-message mention trace is suppressed. Out of scope (kept as console.*): the CLI verbs under src/cli/ (CLI tools are expected to write to stdout/stderr) and Discord's slash command handlers in src/providers/discord/commands/ (would require threading a logger dep into the command module interface, separate refactor). Provider deployments can override the gate with LOG_LEVEL=debug for verbose startup traces. Adds 8 logger-level unit tests; existing test mocks for KernelLogger updated to satisfy the wider interface. No regressions: 215 pass vs. 207 on main, 4 pre-existing Windows-path failures unchanged.
…arify docs - Add logs/ to .gitignore so runtime error logs are never committed - Migrate the 3 leftover console.log/console.warn calls in the Discord disconnect handler to the leveled logger - Clarify logLevel JSDoc: console output is level-gated; only the error file append is unconditional
|
Warning Review limit reached
More reviews will be available in 59 minutes and 36 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (18)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
#48 split formatting into `formatLine` (no timestamp, console) and `formatEntry` (timestamp, file). On Linux this was fine — the journal stamps every line — but on macOS launchd writes raw bytes to `logs/maestro-relay.log`, so `maestro-relay-ctl logs` showed untimestamped debug/info/warn lines. Route all console emitters through `formatEntry(...).trimEnd()`. Linux gets a (redundant) inner ISO timestamp alongside the journal's local-time prefix; macOS gets parity with pre-#48 behavior. `logs/errors.log` unchanged.
* fix(logger): restore wallclock timestamp on console output #48 split formatting into `formatLine` (no timestamp, console) and `formatEntry` (timestamp, file). On Linux this was fine — the journal stamps every line — but on macOS launchd writes raw bytes to `logs/maestro-relay.log`, so `maestro-relay-ctl logs` showed untimestamped debug/info/warn lines. Route all console emitters through `formatEntry(...).trimEnd()`. Linux gets a (redundant) inner ISO timestamp alongside the journal's local-time prefix; macOS gets parity with pre-#48 behavior. `logs/errors.log` unchanged. * chore(logger): remove unused formatLine helper Left over after the macOS timestamp fix routed all console output through formatEntry; formatLine had no remaining callers. Dropping it removes dead code and keeps logger.ts focused on a single line format. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Bundles four merged PRs since v0.2.0: - #46 OS-agnostic auto-run + attachments tests (Windows CI fix) - #47 typed bridge errors + `Retry-After` header on 429 - #48 leveled logger consolidation + `LOG_LEVEL` env var - #49 wallclock ISO timestamps on console output (macOS launchd gap) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@
Summary
Routes all
console.*calls through a single leveled logger (src/core/logger.ts) with a configurableLOG_LEVEL(debug/info/warn/error, defaultinfo).erroralways appends tologs/errors.log; console output for every level is gated byLOG_LEVEL. The logger sanitizes CRLF from context/detail to prevent log injection, and no secrets/tokens are logged.Changes
src/core/logger.ts: leveled logger with file append for errors.console.*call sites acrossapi.ts,attachments.ts,maestro.ts,providers.ts,transcription.ts,index.ts, and the Discord adapters/commands - including the 3 leftover calls in the Discord disconnect handler.src/core/config.ts:logLevelgetter + clarified JSDoc (console output is level-gated; only the error file append is unconditional)..gitignore: addlogs/so runtime error logs are never committed..env.example: documentLOG_LEVEL.Merge order
Independent of #47. Best merged after #46 (Windows path test fixes) so CI is fully green; the only failures on this branch are those 4 pre-existing path tests, which #46 resolves.
Test plan
npm test-> 215 pass (4 failures are the pre-existing Windows path tests fixed by test: make auto-run-command and attachments tests OS-agnostic #46)logger.test.tssuite green (level gating, file append, sanitization)tsc)@