Skip to content

Add comprehensive logging throughout the application#7

Merged
MohammedAlkindi merged 1 commit into
mainfrom
claude/enhance-debug-system-o3Kv8
Apr 2, 2026
Merged

Add comprehensive logging throughout the application#7
MohammedAlkindi merged 1 commit into
mainfrom
claude/enhance-debug-system-o3Kv8

Conversation

@MohammedAlkindi

Copy link
Copy Markdown
Owner

Summary

This PR adds structured logging across the backend and frontend to improve observability and debugging capabilities. A new logging configuration module centralizes log setup, and logging statements are added at key points in the recommendation pipeline and HTTP request handling.

Key Changes

Backend Logging Infrastructure:

  • Created app/logging_config.py with centralized logging configuration that respects LOG_LEVEL environment variable (defaults to INFO)
  • Suppresses noisy uvicorn access logs in DEBUG mode to avoid duplication
  • Uses ISO 8601 timestamp format for consistency

API & Request Logging:

  • Added HTTP middleware in main.py to log all requests with method, path, status code, and duration
  • Enhanced /recommend endpoint with detailed logging:
    • Info-level logs for incoming requests with all preference parameters
    • Debug-level logs for liked/disliked/avoided titles
    • Error handling with try-catch blocks that log failures and return appropriate HTTP 500 errors
    • Info-level logs for successful responses with result count and top score

Scoring Engine Logging:

  • Added debug-level logging in score_item() to show per-item scoring details
  • Added debug-level logging in rank_recommendations() to show ranking results and top scores

Catalog Service Logging:

  • Added debug-level log when loading catalog
  • Added info-level log showing total items loaded

Frontend Logging:

  • Implemented structured logging utility with info/debug/warn/error methods
  • Added curio-debug localStorage flag to enable/disable debug output
  • Logs API request payloads and response details with timing information
  • Logs errors with full error objects for better debugging

Implementation Details

  • All backend loggers use __name__ for proper module identification
  • Logging uses lazy string formatting (%) to avoid unnecessary string construction at lower log levels
  • Frontend logs are prefixed with [Curio] or [Curio:debug] for easy identification
  • Error logging includes exc_info=True for full stack traces
  • Request timing uses time.perf_counter() for high-resolution measurements

https://claude.ai/code/session_016AW7kKjJdbSnspDi1fJ3q7

- New logging_config.py: configures root logger from LOG_LEVEL env var
- main.py: HTTP request timing middleware logs method/path/status/ms
- recommend.py: logs request params, top score, result count; wraps
  catalog load and scoring in try/except with HTTPException on failure
- engine.py: DEBUG-level per-item score traces and ranked list summary
- catalog.py: logs catalog file path and item count on load
- main.js: structured console logger (log.info/debug/error) with
  per-request timing; verbose debug output gated on curio-debug=true
  in localStorage

https://claude.ai/code/session_016AW7kKjJdbSnspDi1fJ3q7
@MohammedAlkindi
MohammedAlkindi merged commit f206aae into main Apr 2, 2026
1 check passed
@MohammedAlkindi
MohammedAlkindi deleted the claude/enhance-debug-system-o3Kv8 branch April 2, 2026 17:22
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.

2 participants