feat: gate verbose logs behind ZCODE_ACP_DEBUG (quiet by default)#6
Conversation
Introduces a two-level logger: warn() always emits perceivable failures (backend pipe errors, fatal exit, turn.failed, command/permission failures, lock/preempt timeouts, model switch failures); log() carries diagnostic detail and is suppressed by default, emitted only when ZCODE_ACP_DEBUG=1. Key failures (21 sites) were migrated from log() to warn() so they remain visible in the default quiet mode; the remaining 61 log() calls are intentional flow tracing / fallback paths. Adds 4 unit tests covering the gating behavior.
There was a problem hiding this comment.
Code Review
This pull request introduces a new environment variable ZCODE_ACP_DEBUG to toggle verbose diagnostic logging, updating various log statements across the codebase to use a newly introduced warn function for always-emitted warnings. Unit tests are added to verify the logging behavior, and documentation is updated accordingly. The review feedback suggests using optional chaining on requestedSchema in src/handlers/server-requests.ts to prevent potential runtime errors, and correcting a minor Markdown formatting issue in README.zh-CN.md.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| log( | ||
| ` ⟳ AskUserQuestion forwarding elicitation/create (form, ${Object.keys(formParams.requestedSchema.properties).length} fields)`, | ||
| ); |
There was a problem hiding this comment.
To prevent potential runtime errors, it is safer to use optional chaining when accessing properties on requestedSchema. If requestedSchema or properties is undefined, calling Object.keys directly will throw a TypeError.
| log( | |
| ` ⟳ AskUserQuestion forwarding elicitation/create (form, ${Object.keys(formParams.requestedSchema.properties).length} fields)`, | |
| ); | |
| log( | |
| ` ⟳ AskUserQuestion forwarding elicitation/create (form, ${Object.keys(formParams.requestedSchema?.properties ?? {}).length} fields)`, | |
| ); |
| | `ZCODE_NODE` | _(自动发现)_ | 显式指定运行 `ZCODE_BIN` 的 Node 二进制(必须支持 `node:sqlite`)| | ||
| | `ZCODE_MODEL` | _(来自 config)| 覆盖当前使用的模型 id | | ||
| | `ZCODE_BASE_URL` | _(来自 config)| 覆盖 provider 的 base URL | | ||
| | `ZCODE_ACP_DEBUG` | _(未设置)| 设为 `1` 可开启详细诊断日志(事件流、探测循环、状态更新)。默认安静——只输出警告类日志(后端管道错误、命令/权限失败、锁等待超时)。诊断桥接问题时开启;日志出现在 `Zed.log` 中,前缀为 `[zcode-acp]`。 | |
There was a problem hiding this comment.
在 README.zh-CN.md 中,_(未设置) 缺少了结尾的下划线 _,导致 Markdown 格式不一致。建议将其修改为 _(未设置)_ 以保持与第 62 行 _(自动发现)_ 一致的斜体格式。
| | `ZCODE_ACP_DEBUG` | _(未设置)| 设为 `1` 可开启详细诊断日志(事件流、探测循环、状态更新)。默认安静——只输出警告类日志(后端管道错误、命令/权限失败、锁等待超时)。诊断桥接问题时开启;日志出现在 `Zed.log` 中,前缀为 `[zcode-acp]`。 | | |
| | `ZCODE_ACP_DEBUG` | _(未设置)_ | 设为 `1` 可开启详细诊断日志(事件流、探测循环、状态更新)。默认安静——只输出警告类日志(后端管道错误、命令/权限失败、锁等待超时)。诊断桥接问题时开启;日志出现在 `Zed.log` 中,前缀为 `[zcode-acp]`。 | |
Summary
Introduces a two-level logger so the bridge is quiet by default — only perceivable failures appear in
Zed.log. Verbose diagnostics are gated behindZCODE_ACP_DEBUG=1and emitted only when explicitly enabled.This keeps
Zed.logclean for stable daily use while preserving the rich diagnostics that were essential for diagnosing the recent compact, mode, and permission bugs (just opt in with the env var).Design
ZCODE_ACP_DEBUG=1Zed.log.Migration (21 `log()` → `warn()`)
Key failures migrated so they stay visible in the default quiet mode. Categorization rule: user-perceivable failures → `warn`; pure flow tracing / graceful-fallback paths → `log`.
The remaining 61 `log()` calls are intentional: `→ ok` success markers, `[event]`/`[probe]`/`[preempt]` tracing, reannounce dedup, startup notices, and catch blocks with graceful fallbacks (model-cache session/read, tasks-index sync).
Verification
Files