Spaces:
Running
Running
Download utils/logging.py from rvdbra/EinbuergDemoforTesting: direct link, hf CLI and curl.
- Browser
- Download file 725 Bytes
-
https://huggingface.co/spaces/rvdbra/EinbuergDemoforTesting/resolve/main/utils/logging.py
- Command line
-
hf download hf://spaces/rvdbra/EinbuergDemoforTesting/utils/logging.py
-
curl -L -o logging.py https://huggingface.co/spaces/rvdbra/EinbuergDemoforTesting/resolve/main/utils/logging.py
725 Bytes
| import logging | |
| import os | |
| from logging.handlers import RotatingFileHandler | |
| LOG_DIR = os.getenv("LOG_DIR", "logs") | |
| os.makedirs(LOG_DIR, exist_ok=True) | |
| log = logging.getLogger("passbot_logger") | |
| log.setLevel(logging.DEBUG) | |
| file_handler = RotatingFileHandler( | |
| os.path.join(LOG_DIR, "app.log"), | |
| maxBytes=5 * 1024 * 1024, | |
| backupCount=5 | |
| ) | |
| file_formatter = logging.Formatter( | |
| "%(asctime)s | %(levelname)s | %(name)s | %(message)s" | |
| ) | |
| file_handler.setFormatter(file_formatter) | |
| log.addHandler(file_handler) | |
| console_handler = logging.StreamHandler() | |
| console_formatter = logging.Formatter( | |
| "%(asctime)s | %(levelname)s | %(message)s" | |
| ) | |
| console_handler.setFormatter(console_formatter) | |
| log.addHandler(console_handler) | |