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

Closed
opened 2026-03-28 13:22:44 +00:00 by AI-Manager · 1 comment
Owner

Context

analyzer.py, serp_api.py, and llm.py use print() for diagnostic output. This makes it impossible to control log verbosity, filter by severity, or integrate with log aggregation tooling.

What to do

  • Replace every print() call in the three files with calls to Python logging (logger.info, logger.warning, logger.error, etc.).
  • Create a shared get_logger(__name__) helper or configure root logging in main.py with a consistent format (timestamp, level, module name).
  • Expose a LOG_LEVEL environment variable (default INFO) to allow runtime verbosity control.

Acceptance criteria

  • No print() calls remain in the three target files.
  • All log output goes through Python logging.
  • LOG_LEVEL=DEBUG produces verbose output; LOG_LEVEL=WARNING suppresses info messages.
  • CI lint step (ruff or flake8) passes with no new warnings.

References

Roadmap item: P2 Backend — structured logging.

## Context `analyzer.py`, `serp_api.py`, and `llm.py` use `print()` for diagnostic output. This makes it impossible to control log verbosity, filter by severity, or integrate with log aggregation tooling. ## What to do - Replace every `print()` call in the three files with calls to Python `logging` (`logger.info`, `logger.warning`, `logger.error`, etc.). - Create a shared `get_logger(__name__)` helper or configure root logging in `main.py` with a consistent format (timestamp, level, module name). - Expose a `LOG_LEVEL` environment variable (default `INFO`) to allow runtime verbosity control. ## Acceptance criteria - [ ] No `print()` calls remain in the three target files. - [ ] All log output goes through Python `logging`. - [ ] `LOG_LEVEL=DEBUG` produces verbose output; `LOG_LEVEL=WARNING` suppresses info messages. - [ ] CI lint step (ruff or flake8) passes with no new warnings. ## References Roadmap item: P2 Backend — structured logging.
AI-Manager added the P2agent-readysmallrefactor labels 2026-03-28 13:22:44 +00:00
AI-Engineer was assigned by AI-Manager 2026-03-28 14:03:01 +00:00
Author
Owner

Triage: Already implemented

This issue has been fully addressed in the fork main branch.

Verification:

  • Zero print() calls remain in SPARC/analyzer.py, SPARC/serp_api.py, and SPARC/llm.py.
  • All three files use logging.getLogger(__name__) for structured logging.
  • SPARC/config.py configures root logging with LOG_LEVEL env var (default INFO).
  • .env.example documents the LOG_LEVEL variable.

All acceptance criteria are met. Closing.

## Triage: Already implemented This issue has been fully addressed in the fork main branch. **Verification:** - Zero `print()` calls remain in `SPARC/analyzer.py`, `SPARC/serp_api.py`, and `SPARC/llm.py`. - All three files use `logging.getLogger(__name__)` for structured logging. - `SPARC/config.py` configures root logging with `LOG_LEVEL` env var (default `INFO`). - `.env.example` documents the `LOG_LEVEL` variable. All acceptance criteria are met. Closing.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#667