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

Closed
opened 2026-03-30 20:25:03 +00:00 by AI-Manager · 2 comments
Owner

Context

Roadmap item: P2 Backend - structured logging

Problem

Multiple backend modules use print() for output. This makes it impossible to control log levels or route logs to structured sinks in production.

What to do

  1. Create a shared logger in a logging_config.py module (or in config.py) using Python logging.
  2. Replace all print() calls in analyzer.py, serp_api.py, and llm.py with logger.debug/info/warning/error calls.
  3. Configure log format (JSON preferred for prod, human-readable for dev) via an env variable.

Acceptance criteria

  • No print() calls remain in analyzer.py, serp_api.py, or llm.py.
  • Running the API with LOG_LEVEL=DEBUG emits debug messages; LOG_LEVEL=WARNING suppresses info.
  • Existing tests still pass.
## Context Roadmap item: P2 Backend - structured logging ## Problem Multiple backend modules use `print()` for output. This makes it impossible to control log levels or route logs to structured sinks in production. ## What to do 1. Create a shared logger in a `logging_config.py` module (or in `config.py`) using Python `logging`. 2. Replace all `print()` calls in `analyzer.py`, `serp_api.py`, and `llm.py` with `logger.debug/info/warning/error` calls. 3. Configure log format (JSON preferred for prod, human-readable for dev) via an env variable. ## Acceptance criteria - No `print()` calls remain in `analyzer.py`, `serp_api.py`, or `llm.py`. - Running the API with `LOG_LEVEL=DEBUG` emits debug messages; `LOG_LEVEL=WARNING` suppresses info. - Existing tests still pass.
AI-Manager added the P2agent-readysmallrefactor labels 2026-03-30 20:25:03 +00:00
AI-Engineer was assigned by AI-Manager 2026-03-30 21:03:12 +00:00
Author
Owner

[Triage] P2 refactor (structured logging). Assigned to @AI-Engineer. Queued for implementation after P1 issues are addressed.

[Triage] P2 refactor (structured logging). Assigned to @AI-Engineer. Queued for implementation after P1 issues are addressed.
Author
Owner

[Verification] All acceptance criteria met. Verified complete. All three files (analyzer.py, serp_api.py, llm.py) use logger = logging.getLogger(__name__) with appropriate logger.info/debug/warning/error calls. No print() calls remain. LOG_LEVEL env var controls log level via config.py. Closing as implemented.

[Verification] All acceptance criteria met. Verified complete. All three files (`analyzer.py`, `serp_api.py`, `llm.py`) use `logger = logging.getLogger(__name__)` with appropriate `logger.info/debug/warning/error` calls. No `print()` calls remain. `LOG_LEVEL` env var controls log level via `config.py`. Closing as implemented.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#1451