Skip to content

chore(observability): prefix log lines with an ISO-8601 UTC timestamp#962

Open
shgew wants to merge 2 commits into
rohitg00:mainfrom
shgew:feat/log-iso8601-prefix
Open

chore(observability): prefix log lines with an ISO-8601 UTC timestamp#962
shgew wants to merge 2 commits into
rohitg00:mainfrom
shgew:feat/log-iso8601-prefix

Conversation

@shgew

@shgew shgew commented Jun 20, 2026

Copy link
Copy Markdown

What

Prefix every log line emitted by logger.fmt, bootLog, and bootWarn with an ISO-8601 UTC timestamp:

2026-06-20T19:30:00.000Z [agentmemory] info Server listening on 3111

Quiet-mode buffered boot lines stay plain to keep the CLI summary clean.

Why

Docker logs and any persisted log file now carry per-line timestamps for downstream tail/grep/log-aggregator work. Without per-line timestamps, multi-container or multi-process log streams cannot be merged chronologically.

Tests

test/logger.test.ts (new file, 5 cases): info, warn, error, field serialization, non-serializable fallback, bootWarn, verbose bootLog. Targeted suite: 5/5 pass.

Compatibility

Format change for runtime log lines. CLI summary unchanged. No env changes.

Summary by CodeRabbit

  • New Features
    • Log output now includes ISO-8601 (UTC) timestamps for improved event tracing and debugging visibility.
  • Tests
    • Added coverage to verify stderr formatting for normal logging and boot-time messages, including behavior when extra fields cannot be serialized.

Prefix every log line emitted by logger.fmt, bootLog, and bootWarn
with an ISO-8601 UTC timestamp: <iso> [agentmemory] <level> <msg>.
Quiet-mode buffered boot lines stay plain to keep the CLI summary
clean.

Docker logs and any persisted log file now carry per-line timestamps
for downstream tail/grep/log-aggregator work.

Tests: test/logger.test.ts (new file) covers info/warn/error,
field serialization, non-serializable fallback, bootWarn, and
verbose bootLog.

Signed-off-by: Hleb Shauchenka <me@marleb.org>
@vercel

vercel Bot commented Jun 20, 2026

Copy link
Copy Markdown

@shgew is attempting to deploy a commit to the rohitg00's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c0cc415a-942a-4c0f-90f5-583dde107b44

📥 Commits

Reviewing files that changed from the base of the PR and between 27c9cfc and df985b5.

📒 Files selected for processing (1)
  • test/logger.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/logger.test.ts

📝 Walkthrough

Walkthrough

src/logger.ts gains a ts() helper that returns new Date().toISOString(). The fmt() formatter, bootLog(), and bootWarn() are updated to prepend this timestamp to every stderr line. A new Vitest suite in test/logger.test.ts spies on process.stderr.write and asserts the ISO-8601 prefix across all log paths.

Changes

Timestamp-prefixed log formatting

Layer / File(s) Summary
ts() helper and fmt/boot timestamp updates
src/logger.ts
Adds a ts() helper returning new Date().toISOString() and updates fmt(), bootLog(), and bootWarn() to prefix every stderr output line with ${ts()} [agentmemory] ….
Vitest timestamp assertions
test/logger.test.ts
Adds ISO_PREFIX regex, spyStderr() mock helper, and a describe("logger timestamps") suite covering logger.info, logger.warn, logger.error (circular reference), bootWarn(), and bootLog() with verbosity toggling and quiet-mode behavior.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 Tick-tock, said the rabbit, time stamps every line,
ISO-8601 clocks now make the log output shine.
[agentmemory] speaks with a timestamp so neat,
bootWarn and bootLog keep a timestamped beat.
No circular reference can silence the clock—
Every error still ticks, every message unlocked! 🕐

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: adding ISO-8601 UTC timestamp prefixes to log lines, which is the core modification across logger.ts and logger.test.ts.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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.

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (1)
test/logger.test.ts (1)

53-60: ⚡ Quick win

Add a quiet-mode regression test for bootLog.

Please add a case asserting setBootVerbose(false) + bootLog(...) does not call process.stderr.write; this guards the stated contract that quiet boot lines stay buffered/non-timestamped.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/logger.test.ts` around lines 53 - 60, Add a new test case after the
existing verbose bootLog test that verifies the quiet-mode behavior of bootLog.
In this test, call setBootVerbose(false), then call bootLog with a test message,
and assert that the stderr spy mock was not called (or has zero calls),
confirming that quiet boot lines do not write to stderr but remain buffered
instead.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@test/logger.test.ts`:
- Around line 53-60: Add a new test case after the existing verbose bootLog test
that verifies the quiet-mode behavior of bootLog. In this test, call
setBootVerbose(false), then call bootLog with a test message, and assert that
the stderr spy mock was not called (or has zero calls), confirming that quiet
boot lines do not write to stderr but remain buffered instead.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7ba7847a-90eb-497e-803a-c67dc8696281

📥 Commits

Reviewing files that changed from the base of the PR and between f6f9e3c and 27c9cfc.

📒 Files selected for processing (2)
  • src/logger.ts
  • test/logger.test.ts

The verbose-mode test asserted the stderr write happens; this adds the
counterpart asserting setBootVerbose(false) + bootLog() does NOT touch
stderr, locking in the buffered/non-timestamped contract.
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