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

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

Summary

Several backend modules use print() for diagnostics. This produces unstructured, unlabelled output that is hard to filter or forward to log aggregators.

What to do

  • Replace all print() calls in analyzer.py, serp_api.py, and llm.py with calls to a logging.getLogger(__name__) logger.
  • Use appropriate log levels: DEBUG for verbose trace output, INFO for milestones, WARNING/ERROR for recoverable/fatal conditions.
  • Configure the root logger in the application entry point with a consistent format (timestamp, level, logger name, message).
  • Ensure LOG_LEVEL can be set via environment variable.

Acceptance Criteria

  • No print() calls remain in the three target files.
  • Running the API with LOG_LEVEL=DEBUG produces timestamped, levelled log lines.
  • Running with LOG_LEVEL=WARNING suppresses debug/info output.
  • Existing tests still pass.

Reference

Roadmap: P2 Backend — Add structured logging.

## Summary Several backend modules use `print()` for diagnostics. This produces unstructured, unlabelled output that is hard to filter or forward to log aggregators. ## What to do - Replace all `print()` calls in `analyzer.py`, `serp_api.py`, and `llm.py` with calls to a `logging.getLogger(__name__)` logger. - Use appropriate log levels: `DEBUG` for verbose trace output, `INFO` for milestones, `WARNING`/`ERROR` for recoverable/fatal conditions. - Configure the root logger in the application entry point with a consistent format (timestamp, level, logger name, message). - Ensure `LOG_LEVEL` can be set via environment variable. ## Acceptance Criteria - [ ] No `print()` calls remain in the three target files. - [ ] Running the API with `LOG_LEVEL=DEBUG` produces timestamped, levelled log lines. - [ ] Running with `LOG_LEVEL=WARNING` suppresses debug/info output. - [ ] Existing tests still pass. ## Reference Roadmap: P2 Backend — Add structured logging.
AI-Manager added the P2agent-readysmallrefactor labels 2026-03-28 16:22:37 +00:00
AI-Engineer was assigned by AI-Manager 2026-03-28 17:03:06 +00:00
Author
Owner

[Repo Manager] Already resolved. All three files use logging.getLogger(name). LOG_LEVEL env var configured in config.py.

Closing as already implemented in the codebase.

[Repo Manager] Already resolved. All three files use logging.getLogger(__name__). LOG_LEVEL env var configured in config.py. Closing as already implemented in the codebase.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#716