feat: expose recommendation streaming api

This commit is contained in:
Justin Visser 2026-08-10 13:41:43 +02:00
parent e8d20158e3
commit 41aa93c3c7
7 changed files with 473 additions and 12 deletions

View file

@ -0,0 +1,30 @@
"""Configure structlog for machine-readable live logs and readable development logs."""
import logging
import structlog
from app.config import AppMode
def configure_logging(app_mode: AppMode) -> None:
"""Install the process logging pipeline for the selected runtime mode."""
logging.basicConfig(level=logging.INFO, format="%(message)s")
renderer: structlog.types.Processor
if app_mode is AppMode.LIVE:
renderer = structlog.processors.JSONRenderer()
else:
renderer = structlog.dev.ConsoleRenderer(colors=False)
structlog.configure(
processors=[
structlog.contextvars.merge_contextvars,
structlog.processors.add_log_level,
structlog.processors.TimeStamper(fmt="iso", utc=True),
structlog.processors.StackInfoRenderer(),
structlog.processors.format_exc_info,
renderer,
],
wrapper_class=structlog.make_filtering_bound_logger(logging.INFO),
logger_factory=structlog.PrintLoggerFactory(),
cache_logger_on_first_use=True,
)