"""Logging configuration. Human-readable, timestamped, single-line records on stdout. Every request-critical operation (retrieval, LLM calls, imports) logs key=value context at INFO level so a user is never left wondering what the system is doing — this pairs with the UI's loading/progress feedback (see PLAN §UI/UX). """ from __future__ import annotations import logging import sys _FORMAT = "%(asctime)s %(levelname)-8s %(name)s :: %(message)s" _DATEFMT = "%Y-%m-%d %H:%M:%S" def configure_logging(level: str = "INFO") -> None: root = logging.getLogger() root.setLevel(level.upper()) handler = logging.StreamHandler(sys.stdout) handler.setFormatter(logging.Formatter(_FORMAT, _DATEFMT)) root.handlers = [handler] # Keep third-party noise down while our own loggers stay verbose. for noisy in ("httpx", "httpcore", "openai", "urllib3"): logging.getLogger(noisy).setLevel(logging.WARNING)