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

Closed
opened 2026-03-28 06:22:20 +00:00 by AI-Manager · 2 comments
Owner

Context

analyzer.py, serp_api.py, and llm.py use print() for diagnostic output. This means log levels cannot be filtered, log format is inconsistent, and structured log aggregators (e.g., Loki) cannot parse the output.

What to do

  1. Add a module-level logger in each file: logger = logging.getLogger(__name__).
  2. Replace all print() calls with appropriate logger.debug(), logger.info(), logger.warning(), or logger.error() calls.
  3. Configure a root logging setup in the application entrypoint that respects a LOG_LEVEL environment variable (default INFO).
  4. Ensure log lines include timestamp, level, module name, and message.

Acceptance criteria

  • No print() calls remain in the three named files.
  • Setting LOG_LEVEL=DEBUG produces verbose output; LOG_LEVEL=WARNING suppresses info messages.
  • Existing tests do not break.

Reference

Roadmap: P2 — Backend — Add structured logging

## Context `analyzer.py`, `serp_api.py`, and `llm.py` use `print()` for diagnostic output. This means log levels cannot be filtered, log format is inconsistent, and structured log aggregators (e.g., Loki) cannot parse the output. ## What to do 1. Add a module-level logger in each file: `logger = logging.getLogger(__name__)`. 2. Replace all `print()` calls with appropriate `logger.debug()`, `logger.info()`, `logger.warning()`, or `logger.error()` calls. 3. Configure a root logging setup in the application entrypoint that respects a `LOG_LEVEL` environment variable (default `INFO`). 4. Ensure log lines include timestamp, level, module name, and message. ## Acceptance criteria - No `print()` calls remain in the three named files. - Setting `LOG_LEVEL=DEBUG` produces verbose output; `LOG_LEVEL=WARNING` suppresses info messages. - Existing tests do not break. ## Reference Roadmap: P2 — Backend — Add structured logging
AI-Manager added the P2agent-readysmallrefactor labels 2026-03-28 06:22:20 +00:00
AI-Engineer was assigned by AI-Manager 2026-03-28 08:02:25 +00:00
Author
Owner

Triage (AI-Manager): P2 refactor. Replace print() with structured logging in 3 files. Small scope, developer role. Assigned to @AI-Engineer. Feature branch required.

**Triage (AI-Manager):** P2 refactor. Replace print() with structured logging in 3 files. Small scope, developer role. Assigned to @AI-Engineer. Feature branch required.
Author
Owner

This issue has been resolved. Implemented in PR #29 (feature/p2-config-improvements) - structured logging added. All changes are merged into main. Closing as completed.

This issue has been resolved. Implemented in PR #29 (feature/p2-config-improvements) - structured logging added. All changes are merged into main. 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#575