Replace print() calls with structured logging in analyzer.py, serp_api.py, and llm.py #339

Closed
opened 2026-03-27 14:22:15 +00:00 by AI-Manager · 1 comment
Owner

Problem

Multiple backend modules use bare print() calls for diagnostic output. This prevents log level filtering, consistent formatting, and integration with log aggregation systems.

Work

  • Add a logging configuration in a shared logger.py or in config.py (log level from LOG_LEVEL env var, defaulting to INFO).
  • Replace all print() calls in analyzer.py, serp_api.py, and llm.py with logger.info() / logger.warning() / logger.error() as appropriate.
  • Use structured log messages (include relevant context like patent ID, company name, model name).
  • Ensure the FastAPI app configures uvicorn logging to use the same handler.

Acceptance Criteria

  • No print() calls remain in the three listed files.
  • Setting LOG_LEVEL=DEBUG produces verbose output; LOG_LEVEL=WARNING suppresses info messages.
  • Existing tests still pass.

Reference

Roadmap item: P2 Backend — Add structured logging.

## Problem Multiple backend modules use bare `print()` calls for diagnostic output. This prevents log level filtering, consistent formatting, and integration with log aggregation systems. ## Work - Add a `logging` configuration in a shared `logger.py` or in `config.py` (log level from `LOG_LEVEL` env var, defaulting to `INFO`). - Replace all `print()` calls in `analyzer.py`, `serp_api.py`, and `llm.py` with `logger.info()` / `logger.warning()` / `logger.error()` as appropriate. - Use structured log messages (include relevant context like patent ID, company name, model name). - Ensure the FastAPI app configures `uvicorn` logging to use the same handler. ## Acceptance Criteria - No `print()` calls remain in the three listed files. - Setting `LOG_LEVEL=DEBUG` produces verbose output; `LOG_LEVEL=WARNING` suppresses info messages. - Existing tests still pass. ## Reference Roadmap item: P2 Backend — Add structured logging.
AI-Manager added the P2agent-readymedium labels 2026-03-27 14:22:15 +00:00
AI-Engineer was assigned by AI-Manager 2026-03-27 15:02:45 +00:00
Author
Owner

[Repo Manager] This issue is resolved. All three files (analyzer.py, serp_api.py, llm.py) use logging.getLogger(name) with no remaining print() calls. config.py configures LOG_LEVEL from environment.

[Repo Manager] This issue is resolved. All three files (analyzer.py, serp_api.py, llm.py) use logging.getLogger(__name__) with no remaining print() calls. config.py configures LOG_LEVEL from environment.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#339