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

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

Context

analyzer.py, serp_api.py, and llm.py use print() for diagnostic output. This means log levels cannot be filtered, output format is inconsistent, and structured log aggregators (e.g., Loki) cannot parse the messages.

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

What to do

  1. Add a logging configuration module (or use FastAPI lifespan) to initialize the root logger with a consistent format (e.g., JSON in production, human-readable in development).
  2. Replace every print() call in analyzer.py, serp_api.py, and llm.py with appropriate logger.debug(), logger.info(), logger.warning(), or logger.error() calls.
  3. Accept a LOG_LEVEL environment variable (default INFO) to control verbosity.

Acceptance criteria

  • No print() calls remain in the three target modules.
  • LOG_LEVEL=DEBUG produces verbose output; LOG_LEVEL=WARNING suppresses info messages.
  • Log lines include timestamp, level, module, and message.
## Context `analyzer.py`, `serp_api.py`, and `llm.py` use `print()` for diagnostic output. This means log levels cannot be filtered, output format is inconsistent, and structured log aggregators (e.g., Loki) cannot parse the messages. Roadmap reference: ROADMAP.md > P2 > Backend > Add structured logging ## What to do 1. Add a `logging` configuration module (or use FastAPI lifespan) to initialize the root logger with a consistent format (e.g., JSON in production, human-readable in development). 2. Replace every `print()` call in `analyzer.py`, `serp_api.py`, and `llm.py` with appropriate `logger.debug()`, `logger.info()`, `logger.warning()`, or `logger.error()` calls. 3. Accept a `LOG_LEVEL` environment variable (default `INFO`) to control verbosity. ## Acceptance criteria - [ ] No `print()` calls remain in the three target modules. - [ ] `LOG_LEVEL=DEBUG` produces verbose output; `LOG_LEVEL=WARNING` suppresses info messages. - [ ] Log lines include timestamp, level, module, and message.
AI-Manager added the P2agent-readysmallrefactor labels 2026-03-30 04:23:09 +00:00
Author
Owner

This issue has been resolved on main. No print() calls remain in SPARC/analyzer.py, SPARC/serp_api.py, or SPARC/llm.py. All modules use the logging module with logger = logging.getLogger(__name__). Closing as complete.

This issue has been resolved on main. No `print()` calls remain in `SPARC/analyzer.py`, `SPARC/serp_api.py`, or `SPARC/llm.py`. All modules use the `logging` module with `logger = logging.getLogger(__name__)`. Closing as complete.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#1200