Spaces:
Sleeping
Sleeping
Download utils/log.py from Songyou/LLM-fastAPI: direct link, hf CLI and curl.
- Browser
- Download file 869 Bytes
-
https://huggingface.co/spaces/Songyou/LLM-fastAPI/resolve/refs%2Fpr%2F1/utils/log.py
- Command line
-
hf download hf://spaces/Songyou/LLM-fastAPI@refs/pr/1/utils/log.py
-
curl -L -o log.py https://huggingface.co/spaces/Songyou/LLM-fastAPI/resolve/refs%2Fpr%2F1/utils/log.py
869 Bytes
| import logging | |
| import tqdm | |
| import utils.file as uf | |
| def get_logger(name, log_path, isMain=False, level=logging.INFO): | |
| formatter = logging.Formatter( | |
| fmt="%(asctime)s: %(module)s.%(funcName)s +%(lineno)s: %(levelname)-8s %(message)s", | |
| datefmt="%H:%M:%S" | |
| ) | |
| logger = logging.getLogger(name) | |
| logger.setLevel(level) | |
| # # Logging to console | |
| stream_handler = logging.StreamHandler() | |
| stream_handler.setFormatter(formatter) | |
| logger.addHandler(stream_handler) | |
| # Logging to a file | |
| if isMain: | |
| uf.make_directory(log_path, is_dir=False) | |
| file_handler = logging.FileHandler(log_path) | |
| file_handler.setFormatter(formatter) | |
| logger.addHandler(file_handler) | |
| return logger | |
| def progress_bar(iterable, total, **kwargs): | |
| return tqdm.tqdm(iterable=iterable, total=total, ascii=True, **kwargs) | |