forked from 0xWheatyz/SPARC
Replace print() calls with structured logging in analyzer.py, serp_api.py, and llm.py #618
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
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
import loggingand create a module-level logger (logger = logging.getLogger(__name__)) inanalyzer.py,serp_api.py, andllm.py.print()call with the appropriate log level (logger.debug,logger.info,logger.warning,logger.error).main.py(format, level fromLOG_LEVELenv var defaulting toINFO).logger.info("Patent fetched", extra={"patent_id": pid})).Acceptance criteria
print()calls remain inanalyzer.py,serp_api.py, orllm.py.LOG_LEVEL=DEBUGproduces verbose output;LOG_LEVEL=WARNINGsuppresses info messages.Closing: already implemented on main. All
print()calls inanalyzer.py,serp_api.py, andllm.pyhave been replaced with structured logging.config.pyconfiguresLOG_LEVELwithlogging.basicConfig.