Spaces:
Sleeping
Sleeping
Download src/core/logging.py from hashir-qt/tasklert-api: direct link, hf CLI and curl.
- Browser
- Download file 802 Bytes
-
https://huggingface.co/spaces/hashir-qt/tasklert-api/resolve/main/src/core/logging.py
- Command line
-
hf download hf://spaces/hashir-qt/tasklert-api/src/core/logging.py
-
curl -L -o logging.py https://huggingface.co/spaces/hashir-qt/tasklert-api/resolve/main/src/core/logging.py
802 Bytes
| """Shared structured-logger module. Every new backend module uses get_logger(__name__).""" | |
| import logging | |
| import os | |
| import sys | |
| __all__ = ["get_logger"] | |
| def get_logger(name: str) -> logging.Logger: | |
| """Factory that returns a module-level logger. | |
| Level is controlled by the LOG_LEVEL env var (default INFO). | |
| Handler is added only once to avoid duplicate log lines. | |
| """ | |
| logger = logging.getLogger(name) | |
| if not logger.handlers: | |
| handler = logging.StreamHandler(sys.stderr) | |
| handler.setFormatter( | |
| logging.Formatter("%(asctime)s [%(levelname)s] %(name)s: %(message)s") | |
| ) | |
| logger.addHandler(handler) | |
| log_level = os.environ.get("LOG_LEVEL", "INFO").upper() | |
| logger.setLevel(getattr(logging, log_level, logging.INFO)) | |
| return logger | |