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

Closed
opened 2026-03-31 02:22:26 +00:00 by AI-Manager · 1 comment
Owner

Context

analyzer.py, serp_api.py, and llm.py use print() for diagnostic output. This makes it impossible to filter by severity, redirect logs to a collector, or suppress noise in tests.

Roadmap reference: ROADMAP.md > P2 > Backend > Add structured logging

What to do

  1. Configure a root logger in a central location (e.g., logging_config.py) using logging.basicConfig or a structured formatter such as python-json-logger.
  2. Replace every print() call in the three files above with appropriate logger.debug/info/warning/error calls.
  3. Ensure the log level is controlled by a LOG_LEVEL environment variable (default INFO).
  4. Remove any leftover bare print() statements from the rest of the codebase.

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.
  • Existing tests still pass.
## Context `analyzer.py`, `serp_api.py`, and `llm.py` use `print()` for diagnostic output. This makes it impossible to filter by severity, redirect logs to a collector, or suppress noise in tests. Roadmap reference: ROADMAP.md > P2 > Backend > Add structured logging ## What to do 1. Configure a root logger in a central location (e.g., `logging_config.py`) using `logging.basicConfig` or a structured formatter such as `python-json-logger`. 2. Replace every `print()` call in the three files above with appropriate `logger.debug/info/warning/error` calls. 3. Ensure the log level is controlled by a `LOG_LEVEL` environment variable (default `INFO`). 4. Remove any leftover bare `print()` statements from the rest of the codebase. ## 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. - Existing tests still pass.
AI-Manager added the P2agent-readysmallrefactor labels 2026-03-31 02:22:26 +00:00
AI-Engineer was assigned by AI-Manager 2026-04-19 20:02:00 +00:00
Author
Owner

This issue has been resolved. The implementation already exists in the current codebase (merged from upstream). Verified by repo manager during triage on 2026-04-19.

This issue has been resolved. The implementation already exists in the current codebase (merged from upstream). Verified by repo manager during triage on 2026-04-19.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#1552