Skip to content

fix: write ERROR/WARN to daily log even when debug is off - #311

Merged
ranxianglei merged 5 commits into
masterfrom
2026-08-16_default-error-logging
Aug 16, 2026
Merged

fix: write ERROR/WARN to daily log even when debug is off#311
ranxianglei merged 5 commits into
masterfrom
2026-08-16_default-error-logging

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Problem

With the default debug: false, the Logger wrote no log files at all — so when a user's task errors out there is zero on-disk evidence. Users had to enable debug: true (which also enables heavy per-request context snapshots) to get any logs.

Change

  • lib/logger.ts: the enable gate moved into write() per level — ERROR and WARN lines are now appended to ~/.config/opencode/logs/acp/daily/<date>.log by default; INFO/DEBUG and per-request context snapshots stay gated behind debug: true.
  • tests/logger.test.ts (new): 4 tests covering disabled/enabled logger across all levels and the log line format.

Verification

  • npx tsc --noEmit clean
  • npm run build OK
  • Full suite: 980 tests, 980 pass, 0 fail
  • CI pre-checks (scripts/ci/check-pr.sh) all passed

Compatibility

No persisted-state, config-schema, or exported-API changes. WARN/ERROR call sites are all rare anomaly paths, so default daily-log volume stays tiny.

@github-actions

github-actions Bot commented Aug 16, 2026

Copy link
Copy Markdown

📦 Built Plugin Artifact

Branch: 2026-08-16_default-error-logging (497cd60)

Option A — Install from npm PR tag (recommended)

opencode plugin opencode-acp@pr-311 --global

Each push to this PR publishes a new version under the pr-311 npm tag.

Option B — Install from GitHub

opencode plugin "github:ranxianglei/opencode-acp#2026-08-16_default-error-logging" --global

Option C — Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf opencode-acp-pr311.tgz
cp -r package/dist ~/.cache/opencode/packages/opencode-acp@latest/node_modules/opencode-acp/dist
  1. Restart opencode to pick up changes.

This comment is automatically updated on each push.

Since PR #311 Logger writes WARN/ERROR to the daily log even when debug
is off, test files creating module-scope new Logger(false) without
redirecting XDG_CONFIG_HOME leaked log lines into the developer's real
config home during npm test (9 lines per full-suite run, verified).

Add tests/test-env.ts (redirects XDG_CONFIG_HOME/XDG_DATA_HOME to
mkdtemp dirs on import) and import it first in the 15 affected files.
apply.ts Phase 1 calls filters inside a messages×parts×filters loop;
with WARN now always persisted (PR #311), a broken filter would write
one daily-log line per message×part per turn. Dedupe by filter name per
pass. Add regression test: 5 messages × always-throwing filter →
exactly 1 warn.
- README/CONFIGURATION (en+zh)/AGENTS: debug now gates INFO/DEBUG +
  context snapshots only; WARN/ERROR always land in daily/<date>.log
- e2e-tier-compression: two new Logger({level:'error'}) sites passed an
  object (truthy → debug-enabled); use new Logger(false) as intended
@ranxianglei
ranxianglei merged commit 49560d9 into master Aug 16, 2026
4 checks passed
@ranxianglei ranxianglei mentioned this pull request Aug 17, 2026
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