Spaces:
Sleeping
Sleeping
Download backend/logging_setup.py from SandeepChakka/store-intelligence: direct link, hf CLI and curl.
- Browser
- Download file 702 Bytes
-
https://huggingface.co/spaces/SandeepChakka/store-intelligence/resolve/main/backend/logging_setup.py
- Command line
-
hf download hf://spaces/SandeepChakka/store-intelligence/backend/logging_setup.py
-
curl -L -o logging_setup.py https://huggingface.co/spaces/SandeepChakka/store-intelligence/resolve/main/backend/logging_setup.py
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()) | |