Skip to content

feat(logcat): add export filters for debug, system, error context, and sensitive content - #1130

Open
3316891527 wants to merge 3 commits into
AAswordman:devfrom
3316891527:feat/logcat-export-presets
Open

feat(logcat): add export filters for debug, system, error context, and sensitive content#1130
3316891527 wants to merge 3 commits into
AAswordman:devfrom
3316891527:feat/logcat-export-presets

Conversation

@3316891527

Copy link
Copy Markdown
Contributor

变更说明 / Description

工具箱「日志查看器」原先会把 AppLogger 文件原样导出。短时间对话就能得到上万行、十几 MB 的完整调试日志,里面还夹着系统提示词和请求体 dump,不利于排查,也不适合把文件发出去。

这个 PR 只改导出过滤:界面上增加五个默认关闭的开关。全关时行为和现在一样,导出完整日志;打开后导出文件会变小。写入频率、崩溃页导出都不变。

背景与动机 / Context and motivation

实测大约 12 分钟就能写出约 4 万行 / 20MB 的 operit.log。体积几乎全是 D 级请求体分片(Gemini / AIService),并带有完整系统提示词。现有导出没有过滤,只能整份拷走。

改动范围 / Changes

  • 工具箱日志导出页增加五个开关,默认全部关闭(全量导出)
    1. 排除调试日志:去掉 V/D
    2. 排除系统日志:去掉 WebView / OkHttp 等噪声 tag
    3. 仅错误上下文:保留最后一条 E/A/F 及其上方总条数的 10%
    4. 隐藏敏感内容:遮盖系统提示词和请求体 dump
    5. 不保留时间:导出时去掉时间戳
  • 开关状态写入 log_export_preferences,下次进入页面仍保留
  • LogcatExportHelper.exportLogs(context) 无参调用仍导出全量,崩溃页继续走这条路径
  • 补充 LogExportFilter 单测和对应文案

不包含:

  • 不改 AppLogger 写入频率或落盘内容
  • 不改崩溃页的「导出错误报告 / 导出应用日志」行为
  • 不做正则过滤

兼容性与风险 / Compatibility and risks

  • 默认行为与现网一致:五个开关全关时仍导出完整日志
  • 过滤只作用于导出文件,不删除设备上的 operit.log
  • 崩溃页继续全量导出,不受这些开关影响
  • 开关可叠加;「仅错误上下文」在筛完其它开关之后按剩余条数的 10% 截取

关联 Issue / Related issue

N/A。没有对应 Issue。这是工具箱日志导出的过滤能力,方便把日志文件缩小后再排查或分享。

验证方式 / Verification

检查或命令:
1. Android Build assembleDebug(fork workflow)
2. Android Tests :app:testDebugUnitTest(fork workflow)
3. 真机打开工具箱 → 日志查看器,逐个打开五个开关后导出,对比文件大小和条数

环境与变体:
- fork 分支 feat/logcat-export-presets,基于 upstream/dev
- 真机 debug 包

结果:
- Android Build 绿(run 34120342966)
- Android Tests 红在上游存量测试编译:DeepseekProviderMediaRoleTest(protected createRequestBody)、XaiProviderReasoningTest(缺失 XaiReasoningMapper)。本 PR 的 LogExportFilterTest 未再出现在失败列表中。
- 真机:默认全关仍为全量;每多开一个开关,导出内容确实变少。

证据 / Evidence

检查清单 / Checklist

  • 我已记录可复现验证和未运行项原因 / Reproducible verification and reasons for unrun checks are recorded
  • 日常开发 PR 的目标分支为 dev;如目标为 main,我已说明这是维护者发布同步 / The target branch is dev for regular work; if it is main, I explained why this is a maintainer-led release sync
  • 我已确认 Candidate checks 覆盖改动范围,并会处理技术失败项 / Candidate checks covers the change scope and technical failures will be addressed
  • 最终 diff 无无关、临时、生成、二进制或敏感内容 / Final diff has no unrelated, temporary, generated, binary, or secret content
  • 已提供对应的回归、UI、文档/字符串或兼容性证据 / Relevant regression, UI, docs/strings, or compatibility evidence is provided

…d sensitive content

Keep full AppLogger writes unchanged. Toolbox export now has five off-by-default
switches that only filter the exported file. Crash report export stays full-log.
The existing string used mediestore while export code referenced mediastore.
joinToString separators were written as raw newlines and broke compilation.
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