Skip to content

feat(logger): add structured JSON logging formatter option (#685) - #748

Open
ravendevhub wants to merge 1 commit into
Core-Foundry:mainfrom
ravendevhub:feat/structured-json-logging-685
Open

feat(logger): add structured JSON logging formatter option (#685)#748
ravendevhub wants to merge 1 commit into
Core-Foundry:mainfrom
ravendevhub:feat/structured-json-logging-685

Conversation

@ravendevhub

Copy link
Copy Markdown

Summary

Resolves #685 by implementing a structured JSON log formatting option (listener/src/utils/json-logger-formatter.ts) capable of emitting standardized, single-line JSON records formatted for log aggregators (Datadog, CloudWatch, Loki) with automated secret redaction.

Changes

  1. JSON Log Formatter (listener/src/utils/json-logger-formatter.ts):
    • Formats log entries with consistent fields: timestamp, level, message, service, environment, requestId, durationMs, and machine-readable error.
    • Supports configuration via STRUCTURED_LOGGING=true or LOG_FORMAT=json (auto-enabled in NODE_ENV=production).
    • Automatically sanitizes and redacts all secrets from log payloads.
  2. Automated Unit Tests (listener/src/utils/json-logger-formatter.test.ts):
    • Tests environment flags detection, standard JSON record structure, and secret non-leakage.
  3. Documentation (docs/STRUCTURED_JSON_LOGGING.md):
    • Schema specification and environment configuration instructions.

Acceptance Criteria

  • JSON-formatted logs can be enabled through configuration.
  • Log records contain consistent fields.
  • Error information remains machine-readable.
  • Secrets and credentials are excluded.

…dry#685)

- Create createStructuredJsonFormat emitting machine-readable NDJSON logs
- Support STRUCTURED_LOGGING=true and LOG_FORMAT=json environment flags
- Standardize log fields: timestamp, level, message, service, requestId, durationMs, error
- Enforce automated secret redaction before JSON serialization
- Add unit test suite in json-logger-formatter.test.ts and docs in docs/STRUCTURED_JSON_LOGGING.md
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.

Add Structured JSON Logging Option

1 participant