feat(logger): add ISO 8601 timestamps to log output (closes #97)#125
Open
komoreka wants to merge 1 commit into
Open
feat(logger): add ISO 8601 timestamps to log output (closes #97)#125komoreka wants to merge 1 commit into
komoreka wants to merge 1 commit into
Conversation
Closes stoneforge-ai#97. - Every log line now starts with the current ISO 8601 timestamp so long-running sf serve smithy output can be scanned or correlated across services without external time markers. - Opt-out: set LOG_TIMESTAMPS=0 (e.g. when piping to systemd/journald). - Adds 14 unit tests covering timestamp format, opt-out, and all four log levels. - Updates three existing steward-scheduler spy assertions to account for the new leading timestamp argument. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an ISO 8601 timestamp prefix to every log line emitted by
createLoggerinpackages/smithy/src/utils/logger.ts.Before:
After:
Closes #97.
Changes
packages/smithy/src/utils/logger.ts: exports a newtimestampsEnabled()helper that readsLOG_TIMESTAMPSfresh on each call (same pattern as the existinggetLogLevel()). ThecreateLoggerfactory's inneremithelper uses it to prependnew Date().toISOString()before the[service-name]prefix when enabled.packages/smithy/src/utils/logger.bun.test.ts: 14 new tests covering timestamp format, opt-out behavior, extra args pass-through, and all four log levels.packages/smithy/src/services/steward-scheduler.test.ts: updated three existing spy assertions to expect the new leading timestamp argument..changeset/logger-timestamps.md: patch bump for@stoneforge/smithy.Opt-out
Set
LOG_TIMESTAMPS=0to disable the prefix:This matches the existing
LOG_LEVELenv-var pattern and is useful when piping to systemd, journald, or any other log aggregator that adds its own timestamps.Test plan
bun test packages/smithy/src/utils/logger.bun.test.tspasses (14/14)NODE_ENV=development npx turbo run typecheck --filter=@stoneforge/smithyclean