feat(core): 更新日志记录级别,增强调试信息

- 将多个模块中的日志记录级别从info调整为debug,以减少生产环境中的日志噪声,同时在调试模式下提供更详细的信息。
- 更新了主窗口、下载管理器、隐私管理器等多个文件的日志记录,确保在调试过程中能够获取到更丰富的上下文信息,便于问题排查和用户反馈。
This commit is contained in:
hyb-oyqq
2025-08-13 11:45:28 +08:00
parent ac2b0112e8
commit 43a66f66a9
14 changed files with 155 additions and 74 deletions

View File

@@ -42,8 +42,8 @@ if __name__ == "__main__":
sys.excepthook = excepthook
# 记录程序启动信息
logger.info(f"Python版本: {sys.version}")
logger.info(f"运行平台: {sys.platform}")
logger.debug(f"Python版本: {sys.version}")
logger.debug(f"运行平台: {sys.platform}")
# 检查配置中是否启用了调试模式
config = load_config()
@@ -51,7 +51,7 @@ if __name__ == "__main__":
# 在应用启动时清理过期的日志文件
cleanup_old_logs(LOG_RETENTION_DAYS)
logger.info(f"已执行日志清理,保留最近{LOG_RETENTION_DAYS}天的日志")
logger.debug(f"已执行日志清理,保留最近{LOG_RETENTION_DAYS}天的日志")
# 如果调试模式已启用,确保立即创建主日志文件
if debug_mode:
@@ -60,17 +60,17 @@ if __name__ == "__main__":
log_dir = os.path.dirname(LOG_FILE)
if not os.path.exists(log_dir):
os.makedirs(log_dir, exist_ok=True)
logger.info(f"已创建日志目录: {log_dir}")
logger.debug(f"已创建日志目录: {log_dir}")
# 记录调试会话信息
logger.info(f"--- 新调试会话开始于 {os.path.basename(LOG_FILE)} ---")
logger.info(f"--- 应用版本: {APP_NAME} ---")
logger.debug(f"--- 新调试会话开始于 {os.path.basename(LOG_FILE)} ---")
logger.debug(f"--- 应用版本: {APP_NAME} ---")
current_time = datetime.datetime.now()
formatted_date = current_time.strftime("%Y-%m-%d")
formatted_time = current_time.strftime("%H:%M:%S")
logger.info(f"--- 日期: {formatted_date} 时间: {formatted_time} ---")
logger.debug(f"--- 日期: {formatted_date} 时间: {formatted_time} ---")
logger.info(f"调试模式已启用,日志文件路径: {os.path.abspath(LOG_FILE)}")
logger.debug(f"调试模式已启用,日志文件路径: {os.path.abspath(LOG_FILE)}")
except Exception as e:
logger.error(f"创建日志文件失败: {e}")