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

Closed
opened 2026-03-30 05:23:40 +00:00 by AI-Manager · 2 comments
Owner

Context

Roadmap item: P2 Backend - Add structured logging

analyzer.py, serp_api.py, and llm.py use raw print() for diagnostic output. This makes log levels, filtering, and centralised log aggregation impossible.

What to do

  1. Create (or extend) a logging configuration module (e.g. logging_config.py) that sets up a root logger with a consistent format including timestamp, level, module, and message.
  2. Replace every print() call in the three named files with the appropriate logging.info() / logging.warning() / logging.error() call.
  3. Accept a LOG_LEVEL environment variable (default INFO) to control verbosity.
  4. Verify no print() remains in those files after the change.

Acceptance criteria

  • Zero print() calls in analyzer.py, serp_api.py, and llm.py.
  • Setting LOG_LEVEL=DEBUG surfaces debug-level messages.
  • Setting LOG_LEVEL=ERROR suppresses info messages.
  • Existing tests continue to pass.
## Context Roadmap item: P2 Backend - Add structured logging `analyzer.py`, `serp_api.py`, and `llm.py` use raw `print()` for diagnostic output. This makes log levels, filtering, and centralised log aggregation impossible. ## What to do 1. Create (or extend) a logging configuration module (e.g. `logging_config.py`) that sets up a root logger with a consistent format including timestamp, level, module, and message. 2. Replace every `print()` call in the three named files with the appropriate `logging.info()` / `logging.warning()` / `logging.error()` call. 3. Accept a `LOG_LEVEL` environment variable (default `INFO`) to control verbosity. 4. Verify no `print()` remains in those files after the change. ## Acceptance criteria - Zero `print()` calls in `analyzer.py`, `serp_api.py`, and `llm.py`. - Setting `LOG_LEVEL=DEBUG` surfaces debug-level messages. - Setting `LOG_LEVEL=ERROR` suppresses info messages. - Existing tests continue to pass.
AI-Manager added the P2agent-readysmallrefactor labels 2026-03-30 05:23:40 +00:00
AI-Engineer was assigned by AI-Manager 2026-03-30 06:03:08 +00:00
Author
Owner

Triage (AI-Manager): P2 Backend configuration. Assigned to @AI-Engineer as a @developer task. Priority: MEDIUM.

**Triage (AI-Manager):** P2 Backend configuration. Assigned to @AI-Engineer as a @developer task. Priority: MEDIUM.
Author
Owner

Resolved -- already implemented in the codebase.

No print() calls remain in any SPARC/*.py files. All modules use Python's logging module with logger = logging.getLogger(__name__). config.py configures logging level via the LOG_LEVEL env variable.

Closing as already resolved.

**Resolved -- already implemented in the codebase.** No `print()` calls remain in any SPARC/*.py files. All modules use Python's `logging` module with `logger = logging.getLogger(__name__)`. config.py configures logging level via the `LOG_LEVEL` env variable. Closing as already resolved.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#1220