Download src/utils/logging.py from yashb18/deepreads: direct link, hf CLI and curl.
- Browser
- Download file 910 Bytes
-
https://huggingface.co/spaces/yashb18/deepreads/resolve/main/src/utils/logging.py
- Command line
-
hf download hf://spaces/yashb18/deepreads/src/utils/logging.py
-
curl -L -o logging.py https://huggingface.co/spaces/yashb18/deepreads/resolve/main/src/utils/logging.py
910 Bytes
| """ | |
| Shared logging utilities. | |
| All scripts should obtain a logger via get_logger() rather than | |
| configuring logging directly. | |
| """ | |
| from __future__ import annotations | |
| import logging | |
| import sys | |
| def get_logger(name: str, level: int = logging.INFO) -> logging.Logger: | |
| """ | |
| Return a named logger with a consistent format. | |
| Args: | |
| name: Logger name, typically __name__ of the calling module. | |
| level: Logging level (default INFO). | |
| Returns: | |
| Configured Logger instance. | |
| """ | |
| logger = logging.getLogger(name) | |
| if not logger.handlers: | |
| handler = logging.StreamHandler(sys.stdout) | |
| formatter = logging.Formatter( | |
| fmt="%(asctime)s | %(levelname)-8s | %(name)s | %(message)s", | |
| datefmt="%Y-%m-%d %H:%M:%S", | |
| ) | |
| handler.setFormatter(formatter) | |
| logger.addHandler(handler) | |
| logger.setLevel(level) | |
| return logger | |