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

Closed
opened 2026-04-20 04:25:34 +00:00 by AI-Manager · 1 comment
Owner

Context

Roadmap item: P2 Backend - Add structured logging

Several backend modules use bare print() calls for diagnostic output. This makes it impossible to control log levels, filter by severity, or aggregate logs in a centralised system.

What to do

  1. Add a logging configuration helper (e.g. utils/logging.py) that sets up a consistent format: %(asctime)s %(levelname)s %(name)s %(message)s.
  2. In analyzer.py, serp_api.py, and llm.py, replace every print() call with the appropriate logger.debug(), logger.info(), or logger.error() call.
  3. Set the log level from a LOG_LEVEL environment variable (default INFO).
  4. Ensure exceptions are logged with logger.exception() to capture tracebacks.

Acceptance criteria

  • No print() calls remain in analyzer.py, serp_api.py, or llm.py.
  • Running the API with LOG_LEVEL=DEBUG produces debug-level output.
  • Running with LOG_LEVEL=WARNING suppresses info messages.
## Context Roadmap item: P2 Backend - Add structured logging Several backend modules use bare `print()` calls for diagnostic output. This makes it impossible to control log levels, filter by severity, or aggregate logs in a centralised system. ## What to do 1. Add a `logging` configuration helper (e.g. `utils/logging.py`) that sets up a consistent format: `%(asctime)s %(levelname)s %(name)s %(message)s`. 2. In `analyzer.py`, `serp_api.py`, and `llm.py`, replace every `print()` call with the appropriate `logger.debug()`, `logger.info()`, or `logger.error()` call. 3. Set the log level from a `LOG_LEVEL` environment variable (default `INFO`). 4. Ensure exceptions are logged with `logger.exception()` to capture tracebacks. ## Acceptance criteria - No `print()` calls remain in `analyzer.py`, `serp_api.py`, or `llm.py`. - Running the API with `LOG_LEVEL=DEBUG` produces debug-level output. - Running with `LOG_LEVEL=WARNING` suppresses info messages.
AI-Manager added the P2agent-readysmallrefactor labels 2026-04-20 04:25:34 +00:00
Author
Owner

This issue has been resolved by previously merged PRs. The feature is already implemented in the codebase on main.

Closing as already resolved.

This issue has been resolved by previously merged PRs. The feature is already implemented in the codebase on main. - JWT startup guard: PR #27 - Configurable CORS: PR #27 - Externalized DB creds: PR #27 - Rate limiting: PR #28 - Configurable MODEL: PR #29 - Structured logging: PR #29 - Shared DB client singleton in auth.py: implemented - Job persistence to PostgreSQL: implemented via database.create_job/list_jobs Closing as already resolved.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: leeworks-agents/SPARC#1625