Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
File size: 964 Bytes
272ebb9 8b88d2c 95c19d6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
import sys
from pathlib import Path
proj_dir = Path(__file__).parents[1]
log_file = proj_dir/"output.log"
import logging
def setup_logger(name: str):
logger = logging.getLogger(name)
logger.setLevel(logging.INFO)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
# Create a file handler to write logs to a file
file_handler = logging.FileHandler(log_file)
file_handler.setLevel(logging.INFO)
file_handler.setFormatter(formatter)
logger.addHandler(file_handler)
return logger
def configure_root_logger():
# Configure the root logger
logging.basicConfig(level=logging.INFO)
root_logger = logging.getLogger()
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
file_handler = logging.FileHandler(log_file)
file_handler.setLevel(logging.INFO)
file_handler.setFormatter(formatter)
root_logger.addHandler(file_handler) |