Skip to content

fix(logger): restore wallclock timestamp on console output (macOS)#49

Merged
chr1syy merged 2 commits into
mainfrom
fix/logger-macos-timestamp
Jun 7, 2026
Merged

fix(logger): restore wallclock timestamp on console output (macOS)#49
chr1syy merged 2 commits into
mainfrom
fix/logger-macos-timestamp

Conversation

@chr1syy

@chr1syy chr1syy commented Jun 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #48stacked on top of chore/logger-consolidation. Routes all console emitters through formatEntry(...).trimEnd() so log lines carry a wallclock ISO timestamp. Closes the macOS-only gap where maestro-relay-ctl logs (which tails the raw launchd output file) had no timestamps on debug/info/warn lines.

Note on the base branch: the base PR (#48) head lives in a fork, so to make this stack reviewable on RunMaestro/Maestro-Relay, the chore/logger-consolidation branch has been mirrored to this repo. Once #48 merges to main, this PR's base will be re-targeted to main (the diff stays the same) and the mirrored base branch can be deleted.

Why

templates/sh.maestro.relay.plist redirects stdout/stderr to a flat logs/maestro-relay.log file. launchd does not stamp lines. Before this PR, a macOS operator saw [INFO] [api/startup] listening on http://... with no time context.

On Linux, StandardOutput=journal in templates/maestro-relay.service means journalctl already adds a local-time prefix. The inner ISO timestamp this PR adds is mildly redundant on Linux but accepted as the simpler design — operators can filter on either timestamp. The alternative (TTY/env-gated formatting) is more code for marginal benefit.

Behavior change

Surface Before After
Linux journalctl Jun 07 10:53:21 host relay[...]: [INFO] [ctx] msg Jun 07 10:53:21 host relay[...]: [2026-06-07T08:53:21.123Z] INFO [ctx] msg
macOS maestro-relay-ctl logs [INFO] [ctx] msg [2026-06-07T08:53:21.123Z] INFO [ctx] msg
logs/errors.log unchanged unchanged

Implementation

  • src/core/logger.ts: emit() helper and the error() console branch now use formatEntry(level, ctx, detail).trimEnd() (the file-append path still uses the un-trimmed formatEntry(...) so the trailing newline lands in errors.log).
  • formatLine is left in place for now in case a future PR wants TTY-gated formatting; it builds cleanly without noUnusedLocals complaint.
  • src/__tests__/logger.test.ts: updated the three regex assertions matching \[LEVEL\] \[ctx\] detail to match \[ISO-ts\] LEVEL \[ctx\] detail$ instead.

Test plan

  • npm test — 219/219 pass with updated regex
  • npm run build — clean
  • Manual macOS smoke (optional): run dev server, confirm console emits ISO timestamps

@coderabbitai

coderabbitai Bot commented Jun 7, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6f4c5e73-2d3b-434c-a669-bda3f02529f3

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/logger-macos-timestamp

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 and others added 2 commits June 7, 2026 12:43
#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.
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>
@chr1syy chr1syy force-pushed the fix/logger-macos-timestamp branch from 379d87c to 645ae83 Compare June 7, 2026 10:44
@chr1syy chr1syy changed the base branch from chore/logger-consolidation to main June 7, 2026 10:44
@chr1syy chr1syy merged commit ed0ac87 into main Jun 7, 2026
1 check passed
@chr1syy chr1syy deleted the fix/logger-macos-timestamp branch June 7, 2026 10:46
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.

1 participant