Skip to content

chore(logger): consolidate console.* behind a leveled logger#48

Merged
chr1syy merged 2 commits into
RunMaestro:mainfrom
jSydorowicz21:chore/logger-consolidation
Jun 7, 2026
Merged

chore(logger): consolidate console.* behind a leveled logger#48
chr1syy merged 2 commits into
RunMaestro:mainfrom
jSydorowicz21:chore/logger-consolidation

Conversation

@jSydorowicz21

Copy link
Copy Markdown
Collaborator

@

Summary

Routes all console.* calls through a single leveled logger (src/core/logger.ts) with a configurable LOG_LEVEL (debug/info/warn/error, default info). error always appends to logs/errors.log; console output for every level is gated by LOG_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.
  • Migrated console.* call sites across api.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: logLevel getter + clarified JSDoc (console output is level-gated; only the error file append is unconditional).
  • .gitignore: add logs/ so runtime error logs are never committed.
  • .env.example: document LOG_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

maestro-relay and others added 2 commits June 5, 2026 22:04
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
@coderabbitai

coderabbitai Bot commented Jun 6, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@jSydorowicz21, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 975885fa-07f6-4d93-8347-603c1c0c7158

📥 Commits

Reviewing files that changed from the base of the PR and between 86aa703 and a8cccc9.

📒 Files selected for processing (18)
  • .env.example
  • .gitignore
  • src/__tests__/logger.test.ts
  • src/__tests__/mockProvider.test.ts
  • src/__tests__/queue.test.ts
  • src/__tests__/server.test.ts
  • src/core/api.ts
  • src/core/attachments.ts
  • src/core/config.ts
  • src/core/logger.ts
  • src/core/maestro.ts
  • src/core/providers.ts
  • src/core/transcription.ts
  • src/core/types.ts
  • src/index.ts
  • src/providers/discord/adapter.ts
  • src/providers/discord/commands/agents.ts
  • src/providers/discord/messageCreate.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@chr1syy chr1syy merged commit 87645c5 into RunMaestro:main Jun 7, 2026
3 checks passed
chr1syy added a commit that referenced this pull request Jun 7, 2026
#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.
chr1syy added a commit that referenced this pull request Jun 7, 2026
* 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>
chr1syy added a commit that referenced this pull request Jun 7, 2026
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>
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.

2 participants