diff --git a/Ref_Audio_Selector/config_param/log_config.py b/Ref_Audio_Selector/config_param/log_config.py index 1cb1fd8..fda5a3c 100644 --- a/Ref_Audio_Selector/config_param/log_config.py +++ b/Ref_Audio_Selector/config_param/log_config.py @@ -1,4 +1,5 @@ import logging +import os import datetime import Ref_Audio_Selector.config_param.config_params as params @@ -15,6 +16,8 @@ def create_general_logger(): console_handler.setFormatter(console_formatter) console_handler.encoding = 'utf-8' # 设置字符编码为utf-8 + os.makedirs(params.log_dir, exist_ok=True) + # 创建一个用于常规日志的处理器 general_handler = logging.FileHandler(f"{params.log_dir}/{current_date}.log", mode='a', encoding='utf-8') # general_handler.setLevel(logging.INFO) @@ -37,6 +40,9 @@ def create_general_logger(): def create_performance_logger(): # 获取当前日期,用于文件名和日志内容 current_date = datetime.datetime.now().strftime('%Y-%m-%d') + + os.makedirs(params.time_log_print_dir, exist_ok=True) + # 创建一个专用于性能监控日志的处理器 performance_handler = logging.FileHandler( f"{params.time_log_print_dir}/{current_date}.log", mode='a', encoding='utf-8')