store-intelligence / backend /logging_setup.py
SandeepChakka's picture
Cursor
Deploy Store Intelligence: API, dashboard, events (no CCTV/binaries)
312fdff
Raw History Blame Contribute Delete
702 Bytes
from __future__ import annotations
import logging
import sys
import uuid
import structlog
def configure_logging(level: str = "INFO") -> None:
structlog.configure(
processors=[
structlog.contextvars.merge_contextvars,
structlog.processors.add_log_level,
structlog.processors.TimeStamper(fmt="iso"),
structlog.processors.JSONRenderer(),
],
wrapper_class=structlog.make_filtering_bound_logger(
getattr(logging, level.upper(), logging.INFO)
),
context_class=dict,
logger_factory=structlog.PrintLoggerFactory(file=sys.stdout),
)
def new_trace_id() -> str:
return str(uuid.uuid4())