Problem
Current logging in backend/src/api/middleware/logger.ts uses plain console.log with a basic timestamp format. This is not machine-parseable, has no log levels, and makes log aggregation (ELK, Datadog, etc.) impossible.
Current State
// logger.ts output format:
// [2024-01-01T00:00:00.000Z] GET /api/tasks 200 45ms
Proposed Solution
- Add
pino as the logging library (fast, structured by default)
- Create
backend/src/logger.ts with configurable levels:
LOG_LEVEL env var (debug/info/warn/error)
- Development: pretty-printed
- Production: JSON output
- Create child loggers per module:
logger.child({ module: 'coordinator' })
logger.child({ module: 'api', correlationId })
- Replace all
console.log/console.error with structured logger
- Redact sensitive fields (API keys, tokens) automatically
Files to Modify
backend/src/api/middleware/logger.ts
backend/src/coordinator/index.ts
backend/src/db/index.ts
backend/src/registry/sync.ts
backend/src/server.ts
- New:
backend/src/logger.ts
Acceptance Criteria
Difficulty
High — touches every file that logs
Labels
backend services enhancement
Problem
Current logging in
backend/src/api/middleware/logger.tsuses plainconsole.logwith a basic timestamp format. This is not machine-parseable, has no log levels, and makes log aggregation (ELK, Datadog, etc.) impossible.Current State
Proposed Solution
pinoas the logging library (fast, structured by default)backend/src/logger.tswith configurable levels:LOG_LEVELenv var (debug/info/warn/error)logger.child({ module: 'coordinator' })logger.child({ module: 'api', correlationId })console.log/console.errorwith structured loggerFiles to Modify
backend/src/api/middleware/logger.tsbackend/src/coordinator/index.tsbackend/src/db/index.tsbackend/src/registry/sync.tsbackend/src/server.tsbackend/src/logger.tsAcceptance Criteria
LOG_LEVELenv var respectedDifficulty
High — touches every file that logs
Labels
backendservicesenhancement