feat: log cmhub download diagnostics in GenerateWorker
GUI 半边配合 ai.py 的 cmhub 下载诊断:格式化「图片下载较慢」warning、 `cover_image_url` 调试行(脱敏 token、debug_only 不写入 SQLite run_log); `_log_run_event` 增加 persist 开关。tests/test_gui.py 覆盖脱敏与不持久化。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
5a09c6662e
commit
979112966e
@@ -2008,6 +2008,27 @@ class GuiTests(TempDirMixin, unittest.TestCase):
|
||||
"detail": "下载完成,1.3MB,耗时 12.4秒",
|
||||
}
|
||||
)
|
||||
ai_cfg["on_event"](
|
||||
{
|
||||
"task": tasks[0],
|
||||
"phase": "cover",
|
||||
"step": "cover_download",
|
||||
"result": "warning",
|
||||
"detail": "图片下载较慢,已用 24.0秒,大小 1.3MB",
|
||||
"level": "warning",
|
||||
}
|
||||
)
|
||||
ai_cfg["on_event"](
|
||||
{
|
||||
"task": tasks[0],
|
||||
"phase": "cover",
|
||||
"step": "cover_image_url",
|
||||
"result": "debug",
|
||||
"detail": "cmhub 图片 URL:https://cdn.example.com/generated.png?token=SECRET-TOKEN",
|
||||
"level": "warning",
|
||||
"debug_only": True,
|
||||
}
|
||||
)
|
||||
ai_cfg["on_event"](
|
||||
{
|
||||
"task": tasks[0],
|
||||
@@ -2046,6 +2067,8 @@ class GuiTests(TempDirMixin, unittest.TestCase):
|
||||
self.assertIn("准备重试 1/2", joined_logs)
|
||||
self.assertIn("cmhub 已返回 image_url,耗时 91.2秒", joined_logs)
|
||||
self.assertIn("下载完成,1.3MB,耗时 12.4秒", joined_logs)
|
||||
self.assertIn("图片下载较慢,已用 24.0秒,大小 1.3MB", joined_logs)
|
||||
self.assertIn("cmhub 图片 URL:https://cdn.example.com/generated.png?token=***", joined_logs)
|
||||
self.assertIn("本地保存完成,JPEG 已保存,耗时 1.1秒,文件 220.0KB", joined_logs)
|
||||
self.assertIn("token=***", joined_logs)
|
||||
self.assertNotIn("SECRET-TOKEN", joined_logs)
|
||||
@@ -2055,6 +2078,8 @@ class GuiTests(TempDirMixin, unittest.TestCase):
|
||||
self.assertIn("[图片] 1/1 商品 51100639510", event_messages)
|
||||
self.assertIn("准备重试 1/2", event_messages)
|
||||
self.assertIn("下载完成,1.3MB,耗时 12.4秒", event_messages)
|
||||
self.assertIn("图片下载较慢,已用 24.0秒,大小 1.3MB", event_messages)
|
||||
self.assertNotIn("cmhub 图片 URL", event_messages)
|
||||
|
||||
self.assert_removed(temp_dir)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user