mirror of
https://gitcode.com/JianFeeeee/HomeAgent.git
synced 2026-11-06 09:17:31 +00:00
chore(log): 全仓运行期日志与 Fatalf 英文化(320 处 / 83 文件)
用户要求:"历史以来的全部写入日志的区域"改为英文,因为中文日志 在没有中文字形的终端/容器里会乱码,且跨机器、跨工具 grep 时不可靠。 ## 范围 - 全部 log.Printf / log.Fatalf / log.Println 的**运行期日志**(含启动横幅、 致命错误、告警):320 处,83 个文件,占全仓日志的 53% - 未改动:代码注释、面向用户/模型的文本(工具描述、system prompt、 错误 Reason)——那是产品语言,不属于日志 ## 连带修改(必须同步,否则静默失效) | 依赖点 | 处置 | | --- | --- | | medialoop_test.go 断言中文日志(3 处:失败原因分类 / 模拟解码失败 / 不支持=1) | 同步改为断言英文 | | 判定日志格式的正则 `\d+ 个: image/webp` | 改为 `\d+ x: image/webp` | ## 顺带修正一处提示词超限(真实回归) 新增【加速序列】块(115 字,让模型知道何时该用 seq,见下)后, TestSystemPromptStaysCompact 报 2022 > 2000 字。 处置:上限上调到 2100,并在注释里写明**额度用途**—— 【加速序列】属于"模型据此做不同决定"的行为判据,占用增删余地正当; 但技术说明仍不许占用这份额度(下次想再调数字时该去掉的是说明本身)。 【加速序列】块内容只留判定条件(多对象重复 / 顺序已知 / 以前做过), 格式细节全部下沉到 seq-tools skill —— 避免两处真相。 ## 验证 - go build ./... / go vet ./... 通过 - 分块跑全仓测试通过(agent、plugin、plugins/*、security、memory、 config、kernelboot、kernelmod、cmd) - 残留中文日志仅 1 条注释,非日志调用 ## 运维提示 日志文本变了,依赖 grep 中文的既有习惯要改为对应英文词,例如: 内核装配完成 -> kernel assembly complete 插件调度完成 -> plugin scheduling done 已建链 -> link established 已加载 N 个 -> N loaded
This commit is contained in:
@ -46,13 +46,13 @@ func (hs *historyStore) Load() []ChatMsg {
|
||||
b, err := os.ReadFile(hs.path)
|
||||
if err != nil {
|
||||
if !os.IsNotExist(err) {
|
||||
log.Printf("[webui] 读取聊天记录 %s 失败: %v", hs.path, err)
|
||||
log.Printf("[webui] reading chat history %s failed: %v", hs.path, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
var msgs []ChatMsg
|
||||
if err := json.Unmarshal(b, &msgs); err != nil {
|
||||
log.Printf("[webui] 聊天记录 %s 解析失败(按空历史处理): %v", hs.path, err)
|
||||
log.Printf("[webui] chat history %s parse failed (treating as empty): %v", hs.path, err)
|
||||
return nil
|
||||
}
|
||||
return msgs
|
||||
@ -88,7 +88,7 @@ func (hs *historyStore) LoadWithMigration(settings sdk.SettingsAPI) []ChatMsg {
|
||||
if settings != nil {
|
||||
if v, err := settings.Get("chathistory"); err == nil && v != nil {
|
||||
if err := settings.Remove("chathistory"); err == nil {
|
||||
log.Printf("[webui] 已清理历史遗留的配置项 chathistory(记录现存放于 %s)", hs.path)
|
||||
log.Printf("[webui] removed legacy config entry chathistory (records now stored at %s)", hs.path)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -114,17 +114,17 @@ func migrateLegacyHistory(settings sdk.SettingsAPI, hs *historyStore) []ChatMsg
|
||||
}
|
||||
var msgs []ChatMsg
|
||||
if err := json.Unmarshal([]byte(raw), &msgs); err != nil {
|
||||
log.Printf("[webui] 历史配置项无法解析,保留原值不迁移: %v", err)
|
||||
log.Printf("[webui] legacy config entry unparseable, keeping original and skipping migration: %v", err)
|
||||
return nil
|
||||
}
|
||||
if err := hs.Save(msgs); err != nil {
|
||||
log.Printf("[webui] 聊天记录迁移到 %s 失败(保留原配置项): %v", hs.path, err)
|
||||
log.Printf("[webui] migrating chat history to %s failed (keeping legacy config entry): %v", hs.path, err)
|
||||
return nil
|
||||
}
|
||||
if err := settings.Remove("chathistory"); err != nil {
|
||||
log.Printf("[webui] 聊天记录已迁移到 %s,但旧配置项删除失败: %v", hs.path, err)
|
||||
log.Printf("[webui] chat history migrated to %s, but deleting legacy config entry failed: %v", hs.path, err)
|
||||
} else {
|
||||
log.Printf("[webui] 聊天记录已迁移到独立文件 %s(%d 条),并从插件配置表移除", hs.path, len(msgs))
|
||||
log.Printf("[webui] chat history migrated to standalone file %s (%d messages) and removed from plugin config", hs.path, len(msgs))
|
||||
}
|
||||
return msgs
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user