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

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

Context

Roadmap item: P2 - Backend - Add structured logging

analyzer.py, serp_api.py, and llm.py use print() for diagnostic output. This makes it impossible to filter by log level, redirect logs to a collector, or control verbosity without code changes.

Work to do

  1. Add a logging setup module (or configure in main.py) that formats log records as JSON or structured text and respects a 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/info/warning/error call.
  3. Scan the rest of the codebase for stray print() calls and convert those as well.
  4. Ensure that sensitive data (API keys, tokens) is never logged.

Acceptance criteria

  • No print() calls remain in analyzer.py, serp_api.py, or llm.py.
  • Log output respects LOG_LEVEL.
  • pytest output is not polluted by log lines at default INFO level during tests.
  • No API keys or secrets appear in log output.
## Context Roadmap item: P2 - Backend - Add structured logging `analyzer.py`, `serp_api.py`, and `llm.py` use `print()` for diagnostic output. This makes it impossible to filter by log level, redirect logs to a collector, or control verbosity without code changes. ## Work to do 1. Add a `logging` setup module (or configure in `main.py`) that formats log records as JSON or structured text and respects a `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/info/warning/error` call. 3. Scan the rest of the codebase for stray `print()` calls and convert those as well. 4. Ensure that sensitive data (API keys, tokens) is never logged. ## Acceptance criteria - No `print()` calls remain in `analyzer.py`, `serp_api.py`, or `llm.py`. - Log output respects `LOG_LEVEL`. - `pytest` output is not polluted by log lines at default `INFO` level during tests. - No API keys or secrets appear in log output.
AI-Manager added the P2agent-readymediumrefactor labels 2026-03-29 04:22:14 +00:00
Author
Owner

Resolved in codebase. All print() calls have been replaced with logging. SPARC/config.py configures logging.basicConfig() with LOG_LEVEL env var. analyzer.py, serp_api.py, and llm.py all use logger = logging.getLogger(name). No print() calls remain in the SPARC package. Closing as implemented.

Resolved in codebase. All print() calls have been replaced with logging. SPARC/config.py configures logging.basicConfig() with LOG_LEVEL env var. analyzer.py, serp_api.py, and llm.py all use logger = logging.getLogger(__name__). No print() calls remain in the SPARC package. Closing as implemented.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#856