feat(logging): persist diagnostics across restarts and redact secrets

Backend half of the logging overhaul.

Retention:
- Keep the last 4 rotated files at 20MB each and stop deleting logs on
  startup, so a crash's prior-run logs survive a restart.
- Apply the persisted log level right after plugin registration instead
  of at the end of setup.
- Bound crash.log with size-based rotation (5MB x 2).

Secret redaction on every log path:
- Proxy: strip userinfo/query from upstream URLs (keep path for
  diagnostics), exact-match redact known auth.api_key/access_token,
  classify request/response bodies instead of logging them, header
  allowlist.
- Redact the Gemini `?key=` in cache-trace endpoints.
- Omit MCP custom-field values (headers may carry tokens).
- Redact deeplink and model-fetch URLs before logging.

Docs:
- FAQ points users to the persistent crash.log for support workflows.
This commit is contained in:
Jason
2026-07-16 10:20:44 +08:00
parent 7f028632b5
commit 22d2872c33
14 changed files with 655 additions and 224 deletions
+8 -3
View File
@@ -275,7 +275,12 @@ If none of the above solutions work:
### Log Files
Attach log files when submitting an Issue:
CC Switch stores logs under its application configuration directory. By default this is `.cc-switch` in your home directory; if you changed the configuration directory in Advanced Settings, use that custom location instead.
- macOS/Linux: `~/.cc-switch/logs/`
- Windows: `%APPDATA%\cc-switch\logs\`
When submitting an Issue, attach the files relevant to the problem:
- General, network, or proxy errors: `~/.cc-switch/logs/cc-switch.log` and its rotated files
- Application crashes: `~/.cc-switch/crash.log`, `crash.log.1`, and `crash.log.2`
- The default Windows location is `C:\Users\<username>\.cc-switch\...`
The runtime log rotates at 20 MB and retains the four most recent archives. Restarting the application does not clear existing logs. Logs may contain runtime environment details, so review them before posting publicly.
+8 -3
View File
@@ -275,7 +275,12 @@ Codex OAuth リバースプロキシは **リバースエンジニアリング
### ログファイル
Issue を提出する際にログファイルを添付できます:
CC Switch のログはアプリケーション設定ディレクトリに保存されます。既定ではホームディレクトリ内の `.cc-switch` です。詳細設定で設定ディレクトリを変更した場合は、その場所を使用してください。
- macOS/Linux`~/.cc-switch/logs/`
- Windows`%APPDATA%\cc-switch\logs\`
Issue を提出する際は、問題に応じて次のファイルを添付してください:
- 一般的なエラー、ネットワーク、プロキシの問題:`~/.cc-switch/logs/cc-switch.log` とローテーション済みファイル
- アプリケーションのクラッシュ:`~/.cc-switch/crash.log`、`crash.log.1`、`crash.log.2`
- Windows の既定パス:`C:\Users\<ユーザー名>\.cc-switch\...`
実行ログは 20 MB ごとにローテーションされ、直近 4 個のアーカイブを保持します。アプリを再起動しても既存ログは削除されません。公開する前に、ログの内容を確認してください。
+8 -3
View File
@@ -275,7 +275,12 @@ Codex OAuth 反向代理通过**逆向工程的 OAuth 流程**访问 ChatGPT 账
### 日志文件
提交 Issue 时可附上日志文件:
CC Switch 的日志位于应用配置目录中。默认配置目录是用户主目录下的 `.cc-switch`;如果你在高级设置中修改过配置目录,请以自定义目录为准。
- macOS/Linux`~/.cc-switch/logs/`
- Windows`%APPDATA%\cc-switch\logs\`
提交 Issue 时,请按问题类型附上:
- 普通错误、网络或代理问题:`~/.cc-switch/logs/` 中的 `cc-switch.log` 及其轮转文件
- 应用崩溃:`~/.cc-switch/crash.log` 及 `crash.log.1`、`crash.log.2`
- Windows 默认路径为 `C:\Users\<用户名>\.cc-switch\...`
运行日志按 20 MB 轮转,并保留最近 4 个归档;重启应用不会再清空已有日志。日志可能包含运行环境信息,公开提交前建议先检查内容。