Skip to content

fix(logging): unified formatter with timestamp, source location, per-request client addr#6

Merged
rdemeritt merged 1 commit into
mainfrom
fix/unified-logging-2026-06-17
Jun 17, 2026
Merged

fix(logging): unified formatter with timestamp, source location, per-request client addr#6
rdemeritt merged 1 commit into
mainfrom
fix/unified-logging-2026-06-17

Conversation

@rdemeritt

Copy link
Copy Markdown
Member

Summary

Unified logging configuration resolving uvicorn default formatter limitations (missing timestamps and source location). Implements dictConfig-based logging with RequestLoggingMiddleware.

Root Cause

Uvicorn's default formatter produced logs without timestamps or file:lineno source location, making debugging and log aggregation difficult.

Solution

  • log_config.py: dictConfig-based logging factory with shared formatter (timestamp, level, logger name, file:lineno)
  • middleware.py: RequestLoggingMiddleware emits per-request summary (client host:port, method, path, status, duration_ms)
  • main.py: Wire configure_logging() and add middleware to app stack

Example Logs

2026-06-17 12:08:30,123 INFO schwab_data_proxy.main: app startup
2026-06-17 12:08:30,456 INFO schwab_data_proxy.middleware: 127.0.0.1:54321 GET /api/health 200 2.5ms

QA Status

✓ APPROVED — 19/19 tests pass, 6/6 QA criteria confirmed

…per-request client addr

Replace basicConfig with dictConfig-based configure_logging(); wire uvicorn
and app root to a shared standard formatter (timestamp + level + name +
file:lineno). Add RequestLoggingMiddleware that emits one line per request
showing client host:port, method, path, status, and duration_ms.
@rdemeritt rdemeritt merged commit e28795b into main Jun 17, 2026
4 checks passed
@rdemeritt rdemeritt deleted the fix/unified-logging-2026-06-17 branch June 17, 2026 16:20
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.

1 participant