Spaces:
Running on Zero
Running on Zero
Download app/utils/logger.py from hoangtaiii/DRIPPY4: direct link, hf CLI and curl.
- Browser
- Download file 972 Bytes
-
https://huggingface.co/spaces/hoangtaiii/DRIPPY4/resolve/main/app/utils/logger.py
- Command line
-
hf download hf://spaces/hoangtaiii/DRIPPY4/app/utils/logger.py
-
curl -L -o logger.py https://huggingface.co/spaces/hoangtaiii/DRIPPY4/resolve/main/app/utils/logger.py
972 Bytes
| """Logging Utility""" | |
| import logging | |
| import sys | |
| from pathlib import Path | |
| from datetime import datetime | |
| class Logger: | |
| def __init__(self, name="VideoStudio", log_dir="logs"): | |
| self.logger = logging.getLogger(name) | |
| self.logger.setLevel(logging.DEBUG) | |
| log_path = Path(log_dir) | |
| log_path.mkdir(exist_ok=True) | |
| timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") | |
| fh = logging.FileHandler(log_path / f"session_{timestamp}.log", encoding='utf-8') | |
| fh.setLevel(logging.DEBUG) | |
| ch = logging.StreamHandler(sys.stdout) | |
| ch.setLevel(logging.INFO) | |
| fmt = logging.Formatter('[%(asctime)s] [%(levelname)s] %(message)s') | |
| fh.setFormatter(fmt) | |
| ch.setFormatter(fmt) | |
| if not self.logger.handlers: | |
| self.logger.addHandler(fh) | |
| self.logger.addHandler(ch) | |
| def get_logger(self): | |
| return self.logger | |
| app_logger = Logger().get_logger() | |