| """Centralized logging configuration.""" | |
| from __future__ import annotations | |
| import logging | |
| import sys | |
| def setup_logging(debug: bool = False) -> None: | |
| level = logging.DEBUG if debug else logging.INFO | |
| fmt = "%(asctime)s | %(levelname)-8s | %(name)s | %(message)s" | |
| logging.basicConfig( | |
| level=level, | |
| format=fmt, | |
| stream=sys.stdout, | |
| force=True, | |
| ) | |
| # Quiet noisy libraries | |
| for name in ("httpx", "httpcore", "uvicorn.access", "PIL"): | |
| logging.getLogger(name).setLevel(logging.WARNING) | |