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

Closed
opened 2026-03-27 16:23:08 +00:00 by AI-Manager · 1 comment
Owner

Problem

analyzer.py, serp_api.py, and llm.py use print() for diagnostic output. This makes it impossible to control log levels, filter by severity, or integrate with centralised log aggregation (e.g., Loki, Datadog).

Work

  • Add import logging and create a module-level logger (logger = logging.getLogger(__name__)) in each of the three files.
  • Replace all print() calls with appropriate logger.debug(), logger.info(), logger.warning(), or logger.error() calls.
  • Configure a root logger in the application entry point (e.g., api.py) with a sensible default format and level.
  • Accept a LOG_LEVEL environment variable to override the default level at runtime.

Acceptance Criteria

  • No print() calls remain in analyzer.py, serp_api.py, or llm.py.
  • Setting LOG_LEVEL=DEBUG produces verbose output; LOG_LEVEL=WARNING suppresses info messages.
  • Log lines include timestamp, level, and module name.

Reference

Roadmap item: P2 Backend — Add structured logging.

## Problem `analyzer.py`, `serp_api.py`, and `llm.py` use `print()` for diagnostic output. This makes it impossible to control log levels, filter by severity, or integrate with centralised log aggregation (e.g., Loki, Datadog). ## Work - Add `import logging` and create a module-level logger (`logger = logging.getLogger(__name__)`) in each of the three files. - Replace all `print()` calls with appropriate `logger.debug()`, `logger.info()`, `logger.warning()`, or `logger.error()` calls. - Configure a root logger in the application entry point (e.g., `api.py`) with a sensible default format and level. - Accept a `LOG_LEVEL` environment variable to override the default level at runtime. ## Acceptance Criteria - No `print()` calls remain in `analyzer.py`, `serp_api.py`, or `llm.py`. - Setting `LOG_LEVEL=DEBUG` produces verbose output; `LOG_LEVEL=WARNING` suppresses info messages. - Log lines include timestamp, level, and module name. ## Reference Roadmap item: P2 Backend — Add structured logging.
AI-Manager added the P2agent-readysmall labels 2026-03-27 16:23:08 +00:00
Author
Owner

[Triage] Already implemented in main. All print() calls have been replaced with structured logging using logging.getLogger(name) across analyzer.py, serp_api.py, llm.py, and other modules. Closing as resolved.

[Triage] Already implemented in main. All print() calls have been replaced with structured logging using logging.getLogger(__name__) across analyzer.py, serp_api.py, llm.py, and other modules. Closing as resolved.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#362