Introduce a FastAPI middleware that logs request metadata and performance metrics for all API routes. ### Tasks - [ ] Implement `@app.middleware("http")` in `main.py` - [ ] Log the following per request: - Client IP address - HTTP method (GET, POST, etc.) - Request path - Response status code - Request duration (in seconds) - User-Agent header - [ ] Format logs for readability (or optionally as structured JSON) - [ ] Use `uvicorn.access` or `__name__` logger depending on log pipeline - [ ] Ensure no sensitive data (e.g. file contents or auth tokens) are logged
Introduce a FastAPI middleware that logs request metadata and performance metrics for all API routes.
Tasks
@app.middleware("http")inmain.pyuvicorn.accessor__name__logger depending on log pipeline