Replace print() calls with structured logging in analyzer, serp_api, and llm modules #644

Closed
opened 2026-03-28 12:22:37 +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 output. This makes it impossible to filter by log level, route logs to structured sinks, or silence verbose output in tests.

What to do

  • Import Python logging and create a module-level logger in each of the three files: logger = logging.getLogger(__name__)
  • Replace all print() calls with appropriate log levels (logger.debug, logger.info, logger.warning, logger.error)
  • Configure a root logging setup in main.py or config.py (format, level controlled by LOG_LEVEL env var, defaulting to INFO)
  • Ensure exceptions are logged with logger.exception(...) to include stack traces

Acceptance criteria

  • No print() calls remain in analyzer.py, serp_api.py, or llm.py
  • Setting LOG_LEVEL=DEBUG produces verbose output; LOG_LEVEL=WARNING suppresses info messages
  • Log output includes timestamp, level, and module name
## Context Roadmap item: P2 Backend — Structured Logging `analyzer.py`, `serp_api.py`, and `llm.py` use `print()` for output. This makes it impossible to filter by log level, route logs to structured sinks, or silence verbose output in tests. ## What to do - Import Python `logging` and create a module-level logger in each of the three files: `logger = logging.getLogger(__name__)` - Replace all `print()` calls with appropriate log levels (`logger.debug`, `logger.info`, `logger.warning`, `logger.error`) - Configure a root logging setup in `main.py` or `config.py` (format, level controlled by `LOG_LEVEL` env var, defaulting to `INFO`) - Ensure exceptions are logged with `logger.exception(...)` to include stack traces ## Acceptance criteria - No `print()` calls remain in `analyzer.py`, `serp_api.py`, or `llm.py` - Setting `LOG_LEVEL=DEBUG` produces verbose output; `LOG_LEVEL=WARNING` suppresses info messages - Log output includes timestamp, level, and module name
AI-Manager added the P2agent-readysmallrefactor labels 2026-03-28 12:22:37 +00:00
Author
Owner

Closing as already implemented. All modules (analyzer.py, serp_api.py, llm.py, storage.py, scheduler.py, webhooks.py) use logging.getLogger(__name__) with structured logging. No print() calls remain in the codebase.

Closing as already implemented. All modules (`analyzer.py`, `serp_api.py`, `llm.py`, `storage.py`, `scheduler.py`, `webhooks.py`) use `logging.getLogger(__name__)` with structured logging. No `print()` calls remain in the codebase.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#644