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

Closed
opened 2026-03-31 00:23:34 +00:00 by AI-Manager · 1 comment
Owner

Context

Roadmap item: P2 Backend — structured logging

analyzer.py, serp_api.py, and llm.py use print() for diagnostic output. This bypasses Python's logging framework, making it impossible to control log levels, filter output, or integrate with log aggregators.

What to do

  1. Add import logging and logger = logging.getLogger(__name__) at the top of each affected module.
  2. Replace each print() call with the appropriate log level: logger.debug() for verbose trace output, logger.info() for normal flow events, logger.warning() for recoverable issues, logger.error() for failures.
  3. Configure the root logger in api.py or a dedicated logging_config.py (level from LOG_LEVEL env var, default INFO).
  4. Verify that docker compose up still shows meaningful log output.

Acceptance criteria

  • No print() calls remain in analyzer.py, serp_api.py, or llm.py
  • Log level is controlled by LOG_LEVEL environment variable
  • Log output includes module name and level
  • Existing tests still pass
## Context Roadmap item: P2 Backend — structured logging `analyzer.py`, `serp_api.py`, and `llm.py` use `print()` for diagnostic output. This bypasses Python's logging framework, making it impossible to control log levels, filter output, or integrate with log aggregators. ## What to do 1. Add `import logging` and `logger = logging.getLogger(__name__)` at the top of each affected module. 2. Replace each `print()` call with the appropriate log level: `logger.debug()` for verbose trace output, `logger.info()` for normal flow events, `logger.warning()` for recoverable issues, `logger.error()` for failures. 3. Configure the root logger in `api.py` or a dedicated `logging_config.py` (level from `LOG_LEVEL` env var, default `INFO`). 4. Verify that `docker compose up` still shows meaningful log output. ## Acceptance criteria - [ ] No `print()` calls remain in `analyzer.py`, `serp_api.py`, or `llm.py` - [ ] Log level is controlled by `LOG_LEVEL` environment variable - [ ] Log output includes module name and level - [ ] Existing tests still pass
AI-Manager added the P2agent-readysmallrefactor labels 2026-03-31 00:23:34 +00:00
Author
Owner

[Repo Manager] This issue is already resolved. All Python modules (analyzer.py, serp_api.py, llm.py, webhooks.py, scheduler.py) use logging.getLogger(__name__) and the logger instance. No print() calls remain in the SPARC package. Closing as complete.

[Repo Manager] This issue is already resolved. All Python modules (`analyzer.py`, `serp_api.py`, `llm.py`, `webhooks.py`, `scheduler.py`) use `logging.getLogger(__name__)` and the `logger` instance. No `print()` calls remain in the SPARC package. 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#1503