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

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

Background

Roadmap item: P2 Backend — Add structured logging

analyzer.py, serp_api.py, and llm.py use print() for diagnostics. This makes it impossible to filter log levels, redirect output to a log aggregator, or produce structured JSON logs for observability tooling.

Task

  1. Replace all print() calls in analyzer.py, serp_api.py, and llm.py with logging.getLogger(__name__) calls at appropriate levels (DEBUG, INFO, WARNING, ERROR).
  2. Configure a root logger in the app entry point with a configurable log level via LOG_LEVEL env var (default INFO).
  3. Optionally support JSON-formatted output via LOG_FORMAT=json env var (using python-json-logger or similar).
  4. Remove any remaining bare print() debug calls across the codebase.

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 messages include module name, level, and timestamp.
  • Existing tests still pass.

Reference

See ROADMAP.md § P2 Backend.

## Background Roadmap item: **P2 Backend — Add structured logging** `analyzer.py`, `serp_api.py`, and `llm.py` use `print()` for diagnostics. This makes it impossible to filter log levels, redirect output to a log aggregator, or produce structured JSON logs for observability tooling. ## Task 1. Replace all `print()` calls in `analyzer.py`, `serp_api.py`, and `llm.py` with `logging.getLogger(__name__)` calls at appropriate levels (`DEBUG`, `INFO`, `WARNING`, `ERROR`). 2. Configure a root logger in the app entry point with a configurable log level via `LOG_LEVEL` env var (default `INFO`). 3. Optionally support JSON-formatted output via `LOG_FORMAT=json` env var (using `python-json-logger` or similar). 4. Remove any remaining bare `print()` debug calls across the codebase. ## 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 messages include module name, level, and timestamp. - [ ] Existing tests still pass. ## Reference See ROADMAP.md § P2 Backend.
AI-Manager added the P2agent-readysmallrefactor labels 2026-03-30 17:23:40 +00:00
Author
Owner

Resolved by PRs #29 and #54 (merged). All print() calls in analyzer.py, serp_api.py, and llm.py have been replaced with structured Python logging. No bare print() calls remain in the SPARC package.

Resolved by PRs #29 and #54 (merged). All `print()` calls in `analyzer.py`, `serp_api.py`, and `llm.py` have been replaced with structured Python logging. No bare `print()` calls remain in the SPARC package.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#1382