Skip to content

#116 [High] Add structured log shipping wired to the shared Winston logger #325

Description

@james2177

Description: src/common/logger.ts provides the shared Winston logger referenced by issue #54's work to route Soroban/sweeper logging through it consistently, but there's no destination beyond stdout — logs aren't shipped anywhere for aggregation, search, or alerting. Add a structured log-shipping transport (e.g. a Winston transport to a log aggregation service) configurable via environment variables.

Problem Statement & Context: As on-chain write paths, the sweeper, and WS gateway all grow more consequential (per issues #43#54), stdout-only logging makes production incident investigation dependent on manually pulling container logs — there's no searchable, retained, cross-instance log store, which will only get harder once the Redis pub/sub multi-instance scaling in issue #34 lands.

Scope & Acceptance Criteria:

  • Add a configurable Winston transport (shipping to a log sink — confirm target with maintainers, e.g. an ELK/Loki/hosted-logging endpoint) to src/common/logger.ts, gated behind an environment variable so local dev/CI remain stdout-only.
  • Ensure shipped logs retain structured fields (request ID from the existing X-Request-Id handling referenced in issue Replace console.log in IntentsSweeperService with the shared winston logger #87, log level, timestamp, service/module name) rather than flattening to plain strings.
  • Out of scope: building dashboards or alerting rules on top of the shipped logs — this issue delivers the shipping mechanism only.

Implementation Guidelines:

  1. Key files: src/common/logger.ts, src/config/configuration.ts, src/config/env.validation.ts (add and validate the new env var(s) per the pattern issue Add correlation/request-ID propagation through logging and error handling #88 audits for completeness).
  2. Ensure the new transport fails safe — if the log-shipping destination is unreachable, the app must not crash or block request handling (buffer/drop with a local warning, don't throw).
  3. Redact sensitive fields before shipping, consistent with the redaction audit scope in issue Extend /health to check Soroban RPC reachability #91 (don't ship key material or unredacted transaction details to a third-party log sink).
  4. Testing: add unit tests confirming the transport is only registered when its env var is set, and an integration-style test confirming a redacted-fields log entry never contains the sensitive values it should strip.

Definition of Done:

  • Log-shipping transport implemented, redaction verified, tested.
  • Acceptance criteria met.
  • PR passes CI with test output.
  • Reviewed and approved.

Resources: src/common/logger.ts, src/config/configuration.ts, src/config/env.validation.ts

Complexity: High (200 points)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions