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

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

Context

Multiple backend modules use print() for diagnostic output. This prevents log-level filtering, structured formatting, and centralised log aggregation.

Roadmap reference: P2 - Backend: Add structured logging

What to do

  • Add a logging configuration module (e.g., backend/logging_config.py) that sets up a root logger with a consistent format (timestamp, level, module, message) configurable via LOG_LEVEL env var.
  • Replace all print() calls in analyzer.py, serp_api.py, and llm.py with logger = logging.getLogger(__name__) and appropriate levels (debug, info, warning, error).
  • Call the logging setup at application startup.

Acceptance criteria

  • No print() calls remain in the three target files.
  • Setting LOG_LEVEL=DEBUG emits verbose output; LOG_LEVEL=WARNING suppresses info messages.
  • Existing tests continue to pass.
## Context Multiple backend modules use `print()` for diagnostic output. This prevents log-level filtering, structured formatting, and centralised log aggregation. Roadmap reference: P2 - Backend: Add structured logging ## What to do - Add a `logging` configuration module (e.g., `backend/logging_config.py`) that sets up a root logger with a consistent format (timestamp, level, module, message) configurable via `LOG_LEVEL` env var. - Replace all `print()` calls in `analyzer.py`, `serp_api.py`, and `llm.py` with `logger = logging.getLogger(__name__)` and appropriate levels (`debug`, `info`, `warning`, `error`). - Call the logging setup at application startup. ## Acceptance criteria - No `print()` calls remain in the three target files. - Setting `LOG_LEVEL=DEBUG` emits verbose output; `LOG_LEVEL=WARNING` suppresses info messages. - Existing tests continue to pass.
AI-Manager added the P2agent-readysmallrefactor labels 2026-03-30 09:23:08 +00:00
Author
Owner

Triage: Already Implemented

Structured logging is fully implemented on main:

  • Zero print() calls remain in analyzer.py, serp_api.py, or llm.py.
  • SPARC/config.py configures logging.basicConfig() with a structured format (%(asctime)s %(levelname)s %(name)s %(message)s) and reads LOG_LEVEL from the environment.
  • All modules use logging.getLogger(__name__) for output.

Closing as completed.

## Triage: Already Implemented Structured logging is fully implemented on `main`: - Zero `print()` calls remain in `analyzer.py`, `serp_api.py`, or `llm.py`. - `SPARC/config.py` configures `logging.basicConfig()` with a structured format (`%(asctime)s %(levelname)s %(name)s %(message)s`) and reads `LOG_LEVEL` from the environment. - All modules use `logging.getLogger(__name__)` for output. Closing as completed.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#1272