feat(core): 增强日志记录和错误处理功能

- 更新日志记录机制,将日志文件存储在程序根目录下的log文件夹中,并使用日期+时间戳格式命名。
- 在多个模块中添加详细的错误处理逻辑,确保在发生异常时能够记录相关信息,便于后续排查。
- 优化UI管理器中的日志文件打开功能,增加对日志文件存在性和大小的检查,提升用户体验。
- 在下载管理器和补丁管理器中增强调试信息的记录,确保在关键操作中提供更清晰的反馈。
This commit is contained in:
欧阳淇淇
2025-08-07 00:31:24 +08:00
parent 19cdd5b8cd
commit d12739baab
16 changed files with 614 additions and 225 deletions

View File

@@ -28,6 +28,16 @@ class IpOptimizer:
最优的 IP 地址字符串,如果找不到则返回 None。
"""
try:
# 解析URL获取协议和主机名
parsed_url = urlparse(url)
protocol = parsed_url.scheme
hostname = parsed_url.netloc
# 如果是HTTPS可能需要特殊处理
is_https = protocol.lower() == 'https'
logger.info(f"协议: {protocol}, 主机名: {hostname}, 是否HTTPS: {is_https}")
cst_path = resource_path("cfst.exe")
if not os.path.exists(cst_path):
logger.error(f"错误: cfst.exe 未在资源路径中找到。")
@@ -107,7 +117,9 @@ class IpOptimizer:
timeout_counter = 0
# 处理输出行隐藏可能包含的URL
cleaned_line = censor_url(line.strip())
# 临时禁用URL隐藏
# cleaned_line = censor_url(line.strip())
cleaned_line = line.strip() # 直接使用原始输出
if cleaned_line:
logger.debug(cleaned_line)
@@ -163,6 +175,16 @@ class IpOptimizer:
最优的 IPv6 地址字符串,如果找不到则返回 None。
"""
try:
# 解析URL获取协议和主机名
parsed_url = urlparse(url)
protocol = parsed_url.scheme
hostname = parsed_url.netloc
# 如果是HTTPS可能需要特殊处理
is_https = protocol.lower() == 'https'
logger.info(f"IPv6优选 - 协议: {protocol}, 主机名: {hostname}, 是否HTTPS: {is_https}")
cst_path = resource_path("cfst.exe")
if not os.path.exists(cst_path):
logger.error(f"错误: cfst.exe 未在资源路径中找到。")
@@ -245,7 +267,9 @@ class IpOptimizer:
timeout_counter = 0
# 处理输出行隐藏可能包含的URL
cleaned_line = censor_url(line.strip())
# 临时禁用URL隐藏
# cleaned_line = censor_url(line.strip())
cleaned_line = line.strip() # 直接使用原始输出
if cleaned_line:
logger.debug(cleaned_line)