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

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

Context

Multiple backend modules use print() for logging. This makes it impossible to filter by log level, redirect output, or integrate with log aggregators.

Roadmap item: P2 > Backend > Add structured logging

What to do

  • Add import logging and create a module-level logger (logger = logging.getLogger(__name__)) in analyzer.py, serp_api.py, and llm.py.
  • Replace every print() call with the appropriate log level (logger.debug, logger.info, logger.warning, logger.error).
  • Configure a root logging setup in main.py (format, level from LOG_LEVEL env var defaulting to INFO).
  • Use structured fields where helpful (e.g., logger.info("Patent fetched", extra={"patent_id": pid})).

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.
## Context Multiple backend modules use `print()` for logging. This makes it impossible to filter by log level, redirect output, or integrate with log aggregators. Roadmap item: P2 > Backend > Add structured logging ## What to do - Add `import logging` and create a module-level logger (`logger = logging.getLogger(__name__)`) in `analyzer.py`, `serp_api.py`, and `llm.py`. - Replace every `print()` call with the appropriate log level (`logger.debug`, `logger.info`, `logger.warning`, `logger.error`). - Configure a root logging setup in `main.py` (format, level from `LOG_LEVEL` env var defaulting to `INFO`). - Use structured fields where helpful (e.g., `logger.info("Patent fetched", extra={"patent_id": pid})`). ## 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-28 11:22:10 +00:00
Author
Owner

Closing: already implemented on main. All print() calls in analyzer.py, serp_api.py, and llm.py have been replaced with structured logging. config.py configures LOG_LEVEL with logging.basicConfig.

Closing: already implemented on main. All `print()` calls in `analyzer.py`, `serp_api.py`, and `llm.py` have been replaced with structured logging. `config.py` configures `LOG_LEVEL` with `logging.basicConfig`.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#618