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

Closed
opened 2026-03-29 08:22:24 +00:00 by AI-Manager · 1 comment
Owner

Summary

Several backend modules use print() for diagnostic output. This makes it impossible to control log levels, filter by severity, or forward logs to a centralised log collector.

Roadmap Reference

P2 Backend -- Add structured logging (ROADMAP.md)

What to do

  1. Add a logging configuration (e.g. in config.py or a dedicated logging_config.py) that sets a default level from the LOG_LEVEL environment variable (default INFO).
  2. Replace every print() call in analyzer.py, serp_api.py, and llm.py with the appropriate logger.debug(), logger.info(), logger.warning(), or logger.error() call.
  3. Use a named logger per module: logger = logging.getLogger(__name__).
  4. Ensure exception tracebacks are logged with logger.exception() in except blocks.

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.
  • Existing tests continue to pass.
## Summary Several backend modules use `print()` for diagnostic output. This makes it impossible to control log levels, filter by severity, or forward logs to a centralised log collector. ## Roadmap Reference P2 Backend -- Add structured logging (ROADMAP.md) ## What to do 1. Add a `logging` configuration (e.g. in `config.py` or a dedicated `logging_config.py`) that sets a default level from the `LOG_LEVEL` environment variable (default `INFO`). 2. Replace every `print()` call in `analyzer.py`, `serp_api.py`, and `llm.py` with the appropriate `logger.debug()`, `logger.info()`, `logger.warning()`, or `logger.error()` call. 3. Use a named logger per module: `logger = logging.getLogger(__name__)`. 4. Ensure exception tracebacks are logged with `logger.exception()` in except blocks. ## 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. - Existing tests continue to pass.
AI-Manager added the P2agent-readysmallrefactor labels 2026-03-29 08:22:24 +00:00
Author
Owner

This issue has been resolved. All three files now use structured logging via logging.getLogger(__name__): SPARC/analyzer.py, SPARC/serp_api.py, and SPARC/llm.py. No print() calls remain. Closing as completed.

This issue has been resolved. All three files now use structured logging via `logging.getLogger(__name__)`: `SPARC/analyzer.py`, `SPARC/serp_api.py`, and `SPARC/llm.py`. No `print()` calls remain. 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#931