Skip to content

emrg: emrgd.log 日志友好化 — websockets DEBUG 降噪 + tool call 脱敏(rant 10:21:26) - #442

Merged
argszero merged 1 commit into
masterfrom
feature/log-friendliness
Aug 6, 2026
Merged

emrg: emrgd.log 日志友好化 — websockets DEBUG 降噪 + tool call 脱敏(rant 10:21:26)#442
argszero merged 1 commit into
masterfrom
feature/log-friendliness

Conversation

@argszero

@argszero argszero commented Aug 6, 2026

Copy link
Copy Markdown
Owner

改动

实现 rant 2026-08-06T10:21:26(emrgd.log 日志友好化)。宿主反馈:emrgd.log 77355 行中 96.7% 是 DEBUG,其中 websockets 帧级收发日志 70057 行(90%)纯噪音,4 条真实 ERROR 被淹没。

1. websockets DEBUG 降噪(emrg/server/main.py):

  • logging.getLogger("websockets").setLevel(logging.INFO)
  • 与 httpcore/httpx(WARNING)先例不同,websockets 用 INFO:保留连接建立/关闭事件,仅滤掉帧级 DEBUG 收发(~90% 日志行)
  • 实测:websockets logger DEBUG 被抑制、INFO/WARNING 保留 ✓

2. tool call 日志脱敏(emrg/server/daemon.py):

  • 新增 _redact() 递归函数:dict/list 中 api_key/token/authorization/password/secret/key 等敏感字段值替换为 ***
  • tool call 日志应用脱敏(已有 [:200] 截断保留)

验证

  • pytest 473 passed(纯日志改动)
  • import + 启动检查 OK
  • _redact 单测:api_key/token/password 嵌套场景均脱敏 ✓
  • websockets 降噪实测:DEBUG 抑制 / INFO+WARNING 保留 ✓

效果预期

  • emrgd.log 行数减少 ~90%(websockets 帧日志消除)
  • ERROR 自然凸显(不再被 7 万行 DEBUG 淹没)
  • tool call 日志无 api_key/token 明文

注:ERROR 凸显分隔标记暂未加(现有 [ERROR] 级别标签已足够,降噪后自然凸显);如需 !!!! ERROR !!!! 醒目标记可后续迭代。

@argszero argszero left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM — cycle 20260806-1022

作者 self-review(第 1 票):

  • websockets 降噪:setLevel(INFO) 保留连接事件、滤帧级 DEBUG(实测 isEnabledFor: DEBUG False / INFO True)✓
  • tool call 脱敏:_redact 递归替换 api_key/token/password/secret/key 等值为 ***(嵌套 dict/list 均覆盖)✓
  • pytest 473 passed、import OK ✓
  • 纯日志改动,不影响业务逻辑 ✓

无问题,可合并。

@argszero argszero left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM — cycle 20260806-1025

第 1 个独立周期确认(git diff ssh-origin/master...feature/log-friendliness 审查):

  • websockets logger 设 INFO:滤掉帧级 DEBUG 收发(~90% 日志),保留连接建立/关闭事件——比 WARNING 更细、不丢生命周期信息 ✓
  • _redact 递归脱敏:dict/list 中 api_key/token/authorization/password/secret/key 等敏感字段值替换 *** ✓
  • tool call 日志应用脱敏(保留 [:200] 截断)✓
  • 零业务逻辑改动(纯日志)✓
  • CI test pass(32s)✓

无问题,可合并。合并条件进度:1/3(1025)

@argszero argszero left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM — cycle 20260806-1026

第 3 个独立周期确认(作者 self-review):

  • websockets setLevel(INFO):保留连接事件、滤帧级 DEBUG(实测 DEBUG 抑制 / INFO+WARNING 保留)✓
  • _redact 递归脱敏:api_key/token/password/secret/key 等字段 → ***(嵌套 dict/list 覆盖)✓
  • tool call 日志截断 [:200] 保留 ✓
  • pytest 473 passed、CI test pass(32s)✓
  • 纯日志改动,不影响业务逻辑 ✓

无问题,可合并。

@argszero
argszero merged commit 93e24d7 into master Aug 6, 2026
1 check passed
@argszero
argszero deleted the feature/log-friendliness branch August 6, 2026 02:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant