Skip to content

fix: wire bootstrap_logging() into app startup -- enable 7-sink logging system #559

@Aureliolo

Description

@Aureliolo

Summary

The observability module (src/synthorg/observability/) implements a complete 7-sink structured logging system (console + synthorg.log + audit.log + errors.log + agent_activity.log + cost_usage.log + debug.log) with JSON formatting, log rotation, sensitive field redaction, correlation tracking, and per-logger name routing. None of it is active. All logs go to stdout via Uvicorn's default handler.

Root Cause

bootstrap_logging() (in synthorg.config.loader) is exported but never called. The Docker CMD runs:

CMD ["/app/.venv/bin/uvicorn", "synthorg.api.app:create_app", "--factory"]

create_app() never calls bootstrap_logging() or configure_logging(). So structlog falls through to stdlib's root handler (Uvicorn's StreamHandler), and no file sinks are created.

Scope

  • Call bootstrap_logging() in create_app() (or the Litestar on_startup hook) before any other setup
  • Make log_dir configurable via env var SYNTHORG_LOG_DIR (default: /data/logs in Docker, logs locally)
  • Ensure /data/logs is under the existing synthorg-data Docker volume (it already mounts /data)
  • Add SYNTHORG_LOG_DIR=/data/logs to docker/.env.example
  • Verify all 7 sinks activate and files are created with correct routing

Acceptance Criteria

  • bootstrap_logging() is called during app initialization
  • All 7 default sinks are active (console + 6 files)
  • Log files appear in /data/logs/ inside the container (persisted via volume)
  • audit.log receives only synthorg.security.* events
  • agent_activity.log receives only synthorg.engine.* and synthorg.core.* events
  • cost_usage.log receives only synthorg.budget.* and synthorg.providers.* events
  • errors.log receives only ERROR+ events
  • debug.log receives all DEBUG+ events
  • JSON format in all file sinks, colored console format on stderr
  • Log rotation works (RotatingFileHandler, 10MB x 5 backups)
  • SYNTHORG_LOG_DIR env var is respected
  • Tests verify logging bootstrap is called

Metadata

Metadata

Assignees

No one assigned

    Labels

    prio:highImportant, should be prioritizedscope:smallLess than 1 day of workspec:architectureDESIGN_SPEC Section 15 - Technical Architecturetype:fixBug fixes and corrections

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions