M2.5.1: Structured application logger #27
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/structured-logging"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes Issue #24
Summary
Adds an operational logging layer (
obs/) using structlog, separate from the existing JSONL trace logs. Traces remain the researcher provenance audit trail; these new logs cover system events (startup, errors, MCP transport, research lifecycle) and are designed to be ingested into OpenSearch from day one.Backend
MARCHWARDEN_LOG_FORMAT=json|consolelogging(anthropic SDK, httpx, mcp SDK) funneled through the same pipeline; noisy loggers quieted to WARN unless DEBUG is requestedMARCHWARDEN_LOG_FILE=1Context binding
At the start of each
research()call,trace_idandresearcherare bound viastructlog.contextvars. Every downstream log line in that scope automatically carries them — no threading through call sites. Cleared on completion.Wired into
cli.main.cli— configures logging on startup; logsask_started/ask_completed/ask_failedresearchers.web.server.main— configures logging on startup; logsmcp_server_startingresearchers.web.agent.research— binds trace context; logsresearch_started/research_completedVerified
JSON output:
Console output:
Tests
6 new tests covering JSON format, console format, contextvar propagation, level filtering, idempotency, and auto-configure-on-first-use. 94/94 passing.
Out of scope
marchwarden costscommand (M2.5.3 / Issue #26)