forked from 0xWheatyz/SPARC
Replace print() calls with structured Python logging in analyzer.py, serp_api.py, and llm.py #787
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
Several backend modules use
print()for diagnostic output. This means log levels cannot be filtered, output format is inconsistent, and log aggregation tools (e.g., Loki, CloudWatch) cannot parse structured fields.Roadmap reference: ROADMAP.md -- P2 Backend -- "Add structured logging"
What to do
config.py) that sets up a root logger with a configurable level (LOG_LEVELenv var, defaulting toINFO).analyzer.py,serp_api.py, andllm.py, replace everyprint(...)call with the appropriatelogging.getLogger(__name__).<level>(...)call.logger.info("patent fetched", extra={"patent_id": pid})).LOG_FORMAT=jsonis set.Acceptance criteria
print()calls remain in the three target modules.LOG_LEVEL=DEBUGemits debug messages;LOG_LEVEL=WARNINGsuppresses info messages.Triage: Assigned to @developer. Reason: P2 refactor, small - replace print with logging.
Already implemented -- closing.
All modules in the
SPARC/package uselogging.getLogger(__name__)instead ofprint(). A codebase search forprint()calls inSPARC/returns zero results. Specifically:analyzer.py,serp_api.py, andllm.pyall importloggingand uselogger.info(),logger.warning(), andlogger.error(). Theconfig.pymodule configures the logging level via theLOG_LEVELenvironment variable.No further work needed.