first commit
This commit is contained in:
19
atlas_rag/logging.py
Normal file
19
atlas_rag/logging.py
Normal file
@ -0,0 +1,19 @@
|
||||
import logging
|
||||
from logging import Logger
|
||||
from logging.handlers import RotatingFileHandler
|
||||
import os
|
||||
import datetime
|
||||
from atlas_rag.evaluation.benchmark import BenchMarkConfig
|
||||
|
||||
def setup_logger(config:BenchMarkConfig, logger_name = "MyLogger") -> Logger:
|
||||
date_time = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
|
||||
log_file_path = f'./log/{config.dataset_name}_event{config.include_events}_concept{config.include_concept}_{date_time}.log'
|
||||
logger = logging.getLogger(logger_name)
|
||||
logger.setLevel(logging.INFO)
|
||||
max_bytes = 50 * 1024 * 1024
|
||||
if not os.path.exists(log_file_path):
|
||||
os.makedirs(os.path.dirname(log_file_path), exist_ok=True)
|
||||
handler = RotatingFileHandler(log_file_path, maxBytes=max_bytes, backupCount=5)
|
||||
logger.addHandler(handler)
|
||||
|
||||
return logger
|
||||
Reference in New Issue
Block a user