修改日志结构

This commit is contained in:
xinzhu.yin
2026-04-29 16:43:31 +08:00
parent 377bba2a0b
commit afd83448ed
6 changed files with 216 additions and 46 deletions

View File

@@ -1,7 +1,6 @@
import ttkbootstrap as ttk
import tkinter as tk
from tkinter import messagebox, filedialog
import sys
import threading
import time
import os
@@ -23,6 +22,7 @@ from app.views.panels import cct_panel as _ccp
from app.views.panels import main_layout as _main
from app.views.panels import ai_image_panel as _aip
from app.views import panel_manager as PM
from app.logging_setup import setup_logging, attach_gui_handler
# Step 0/1 重构:资源工具和纯算法已迁移到 app/ 包,这里重新导入以保持
# 对原函数名/方法名的向后兼容(老代码内部仍用 self.calculate_* 调用)。
@@ -877,17 +877,13 @@ class PQAutomationApp:
def main():
try:
# 全局日志:默认 INFO 输出到 stderr便于排查 AI 接口等关键事件
import logging as _logging
if not _logging.getLogger().handlers:
_logging.basicConfig(
level=_logging.INFO,
format="%(asctime)s [%(levelname)s] %(name)s: %(message)s",
datefmt="%H:%M:%S",
)
setup_logging()
# root = tk.Tk()
root = ttk.Window(themename="yeti")
app = PQAutomationApp(root)
# GUI 创建完成后,把 logging 记录同步到日志面板
if hasattr(app, "log_gui"):
attach_gui_handler(app.log_gui)
root.mainloop()
except Exception as e:
print("程序发生错误:", e)