Spaces:
Sleeping
Sleeping
Download src/utils/logging.py from Ruurd/semantic-harmonization-api: direct link, hf CLI and curl.
- Browser
- Download file 1.21 kB
-
https://huggingface.co/spaces/Ruurd/semantic-harmonization-api/resolve/main/src/utils/logging.py
- Command line
-
hf download hf://spaces/Ruurd/semantic-harmonization-api/src/utils/logging.py
-
curl -L -o logging.py https://huggingface.co/spaces/Ruurd/semantic-harmonization-api/resolve/main/src/utils/logging.py
1.21 kB
| import logging | |
| import sys | |
| _CONFIGURED = False | |
| # Silence noisy third-party libraries (sentence-transformers/httpx/huggingface_hub | |
| # log INFO-level HTTP requests and an "unauthenticated requests" warning on every | |
| # model load) — none of this is actionable for local, cached model usage. | |
| _QUIET_LOGGERS = ("sentence_transformers", "httpx", "huggingface_hub") | |
| def get_logger(name: str) -> logging.Logger: | |
| global _CONFIGURED | |
| if not _CONFIGURED: | |
| logging.basicConfig( | |
| level=logging.INFO, | |
| format="%(asctime)s [%(levelname)s] %(name)s: %(message)s", | |
| stream=sys.stdout, | |
| ) | |
| for quiet_logger in _QUIET_LOGGERS: | |
| logging.getLogger(quiet_logger).setLevel(logging.ERROR) | |
| try: | |
| # huggingface_hub emits its "unauthenticated requests" notice through | |
| # its own verbosity control rather than a plain logger level, so the | |
| # logger.setLevel above alone doesn't always suppress it. | |
| from huggingface_hub.utils import logging as hf_logging | |
| hf_logging.set_verbosity_error() | |
| except ImportError: | |
| pass | |
| _CONFIGURED = True | |
| return logging.getLogger(name) | |