Spaces:
Running on Zero
Running on Zero
Download logging_setup.py from fffiloni/ZONOS3-Mini: direct link, hf CLI and curl.
- Browser
- Download file 658 Bytes
-
https://huggingface.co/spaces/fffiloni/ZONOS3-Mini/resolve/main/logging_setup.py
- Command line
-
hf download hf://spaces/fffiloni/ZONOS3-Mini/logging_setup.py
-
curl -L -o logging_setup.py https://huggingface.co/spaces/fffiloni/ZONOS3-Mini/resolve/main/logging_setup.py
658 Bytes
| """Keep lifecycle/status diagnostics without logging URL query credentials.""" | |
| import logging | |
| import re | |
| class QueryRedactingFormatter(logging.Formatter): | |
| def format(self, record): | |
| message = super().format(record) | |
| return re.sub(r'(https?://[^\s?"<>]+)\?[^\s"<>]+', r'\1?[redacted]', message) | |
| def configure_logging(): | |
| pattern = "%(asctime)s %(name)s %(levelname)s %(message)s" | |
| logging.basicConfig(level=logging.INFO, format=pattern) | |
| # Format after exception rendering too; preserve method, path and HTTP status. | |
| for handler in logging.getLogger().handlers: | |
| handler.setFormatter(QueryRedactingFormatter(pattern)) | |