Skip to content

fix(log): honor RUST_LOG at -v and -vv, not just -v 0 - #2901

Merged
max-sixty merged 1 commit into
mainfrom
rust-log-honored-at-v
May 25, 2026
Merged

max-sixty merged 1 commit into
mainfrom
rust-log-honored-at-v

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Summary

wt's -v 0 (no flag) honors RUST_LOG — RUST_LOG=debug wt list shows debug records. -v and -vv silently ignored it: they hardcoded filter_level(Info) / filter_level(Debug) and dropped any RUST_LOG directives on the floor.

Now all three verbosity levels flow through the same builder shape: the flag sets a baseline (Off / Info / Debug), and env_logger::Builder::parse_default_env() layers RUST_LOG on top. When RUST_LOG is set it wins (raising or lowering the level, and supporting per-target directives like worktrunk=trace). When it's unset the flag baseline stands.

Examples:

  • bare wt → Off (silent, unchanged)
  • RUST_LOG=debug wt → Debug (unchanged)
  • wt -v → Info (unchanged)
  • RUST_LOG=trace wt -vv → Trace globally (was silently capped at Debug)
  • RUST_LOG=worktrunk=trace wt -v → Info + Trace for worktrunk (was silently ignored)

The flag still owns the file-sink side effects (-vv+ opens trace.log / output.log); only the level filter is now RUST_LOG-aware.

Design choice

Three patterns are common in Rust CLIs:

  1. env wins when set, flag is the default (env_logger convention; e.g. cargo via CARGO_LOG)
  2. flag wins when both are set (e.g. ripgrep, which doesn't honor RUST_LOG at all and uses its own --debug / --trace)
  3. max(flag, env) with per-target additions

I picked (1). The task framing makes the case directly — RUST_LOG users are debugging and know exactly what they want; the flag-only user wants a level; the two shouldn't fight silently. (1) is also the documented env_logger pattern (builder.filter_level(...); builder.parse_default_env();) and gives the smallest implementation. (3) was tempting for "the verbose user always wins", but it's not natively supported by env_logger — extracting just the env's global-wildcard level (not its per-target ceilings) has no clean API, and any hand-rolled merge complicates an otherwise five-line function for the small win of "RUST_LOG=warn doesn't downgrade wt -vv".

Adjacent fix

src/testing/mod.rs::configure_cli_command was setting RUST_LOG=warn as a blanket default for every CLI test. That was harmless under the old behavior (the flag overrode it at -vv); under the new behavior it would silently cap all -vv tests at Warn, starving trace.log of the debug-level [wt-trace] records the diagnostic tests assert on. Dropped the default; the one test that genuinely needed the warn-level diagnostic (test_list_full_with_invalid_configured_platform, asserting on the log::warn! for invalid CI platform) opts in via cmd.env("RUST_LOG", "warn") per-invocation.

Test plan

  • New test_rust_log_overrides_verbose_flag in tests/integration_tests/diagnostic.rs — asserts -v alone suppresses [wt-trace] records (Info baseline) and RUST_LOG=debug wt -v surfaces them (env raises).
  • Existing test_rust_log_debug_fallback_without_vv still covers RUST_LOG=debug at -v 0.
  • All 3835 tests in cargo run -- hook pre-merge --yes pass.

Previously `-v` and `-vv` hardcoded `filter_level(Info)` / `filter_level(Debug)`
and silently dropped `RUST_LOG`. Now all three levels share one builder shape:
the flag sets a baseline (Off / Info / Debug) and `parse_default_env()` layers
`RUST_LOG` on top, so `RUST_LOG=trace wt -vv` and `RUST_LOG=worktrunk=trace wt -v`
do what the user asked. The flag still owns the file-sink side effects at -vv.

Adjacent: dropped `RUST_LOG=warn` from `configure_cli_command` (it would now
cap every -vv test at Warn); the one test that needs the warn-level diagnostic
opts in per-invocation.
@max-sixty
max-sixty merged commit 6732433 into main May 25, 2026
36 checks passed
@max-sixty
max-sixty deleted the rust-log-honored-at-v branch May 25, 2026 21:58
@max-sixty max-sixty mentioned this pull request May 26, 2026
max-sixty added a commit that referenced this pull request May 26, 2026
v0.54.0.

`cargo semver-checks` reports 3 breaking library API changes
(`shell_exec::set_output_log_available` removed,
`SUBPROCESS_TERMINAL_TARGET` removed, `Deprecations::{pre_start,
post_start}` removed) — none of them intentional API, but they force
minor pre-1.0.

Headline user-visible changes:
- New rate-limit pace segment in the Claude Code statusline (#2899,
#2911).
- `wt step prune` streams removals and skips unapproved hooks instead of
prompting mid-scan; default `--min-age` raised 1h → 1d (#2908, #2910,
#2886).
- `-vv` no longer floods stderr — debug routes to `trace.log`, Info
stays on stderr; raw subprocess sink renamed `output.log` →
`subprocess.log`; `RUST_LOG` honored at every verbosity level (#2892,
#2901, #2913).
- Data-safety fixes across merge / remove / prune lifecycle (#2870).
- Legacy shell-wrapper deprecation warning (#2880).

Full CHANGELOG entry in this PR.
max-sixty added a commit that referenced this pull request Jun 12, 2026
…rial path (#3052)

## Summary

Lands the cutover announced in v0.37.0 (#2135): a multi-entry table hook
now runs its commands concurrently for every hook type. `[pre-merge]`
with several keys behaves like `[post-start]` with several keys and like
a single `[[pre-merge]]` block — one execution semantic for `Concurrent`
steps.

The serial behavior was not implemented where one might expect. The
executor's serial branch (`ForegroundStep.concurrent` /
`SourcedStep.is_pipeline` / `CommandConfig::is_pipeline()`) was mostly
dead: the deprecation shipped with a load-time TOML migration that
rewrote multi-entry pre-* tables into serial pipeline form in memory on
every config load, so affected configs never reached the executor as
`Concurrent` steps. Removing that migration (now a `DEPRECATION_RULES`
row, after #3045) is the actual behavior change; the executor flags come
out with it.

## Why no replacement runtime warning

Affected configs have printed a warning on every `wt` invocation for
twenty minor releases (v0.37.0, April 12 → v0.57.0), with `wt config
update` offering a one-command migration that preserved serial behavior
explicitly ("migrate now to keep the current serial behavior once the
table form is repurposed"). A post-cutover warning has no coherent
shape: table form is now legitimate concurrent config, so it would nag
users who want exactly that behavior with no way to silence it, and the
`wt config update` rewrite would no longer be behavior-preserving.

## Parse normalization

A one-entry top-level table previously parsed as a `Concurrent` group of
one; with the serial branch gone it would have picked up `name │` output
prefixes. One-entry maps now parse as `Single(named)` everywhere,
matching one-entry maps inside pipeline lists (removing the documented
dict-at-top vs dict-in-list asymmetry), and a new `Serialize` arm keeps
one-step named configs round-tripping as named tables. Single-entry
table hooks render exactly as before.

## Behavior changes

1. **Multi-entry table-form pre-* hooks: serial → concurrent.** The
announced change.
2. **`wt hook <post-type>` foreground runs of multi-entry table hooks:
serial → concurrent.** Previously an undocumented inconsistency — the
same config already ran concurrently via the background path.
3. **Single-entry table aliases (`[aliases.x]` with one key):
prefixed-stderr → stdout passthrough.** Now matches the string and
`[[aliases.x]]` spellings, and makes `wt <alias> | …` work for this
spelling too.

(2) and (3) were never deprecation-warned; all three belong in the
release notes.

## Tests

- `test_pre_merge_deprecated_table_runs_serially` → rewritten as
`test_pre_merge_table_form_runs_concurrently`; the
single-`[[pre-merge]]`-block test is deleted (both forms now parse
identically, so it duplicated the rewritten test).
- Fixtures that genuinely need serial ordering (`>`/`>>` chains, the
signal-abort "second must not run" assertion) converted to pipeline
form.
- `test_user_hooks_preserve_toml_order` (#737) and
`test_post_start_named_commands` keep table form and pin ordering via
`WORKTRUNK_TEST_SERIAL_CONCURRENT=1`, so insertion order is still
asserted through the real concurrent input ordering.
- New: one-entry-table parse/round-trip unit test;
`test_alias_single_entry_table_writes_to_stdout` pinning change (3).
- Regenerated snapshots drop a stale `RUST_LOG: warn` env line (the
harness stopped setting it in #2901).

## Known follow-up

Concurrent-group announcements expose a pre-existing ANSI dim-bleed:
`format_bash_with_gutter` output ends without closing the dim attribute,
so back-to-back `◎ Running …` lines render dim (visible today on
pipeline-form hooks and `--execute` verbose). Now that this rendering is
the table-form default it's worth fixing, but the fix lives in the
gutter formatter and churns every bash-gutter snapshot — separate PR.

> _This was written by Claude Code on behalf of max_

---------

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
worktrunk 0.54.0

Created-by: HarmonybrewBot
Commit-by: HarmonybrewBot
Merged-by: HarmonybrewBot
Description: Created by `brew bump`

---

Created with `brew bump-formula-pr`.<details>
  <summary>release notes</summary>
  <pre>## Release Notes

### Improved

- **Rate-limit pace segment in the Claude Code statusline**: `wt list statusline --format=claude-code` now surfaces a yellow `1.3×pace(10am–3pm)` segment when Claude Code's reported five-hour or seven-day rate-limit window is on track to be hit before its reset. The segment uses a Bayesian forecast on `P(final ≥ 100%)` so early-window bursts (e.g., 5% used at 3% elapsed) don't trigger spurious warnings — only the worse-projected of the two windows is shown, and the segment is hidden entirely when both are safe. The clock format inside the parentheses honors `LC_ALL` / `LC_TIME` / `LANG`: `en_US`/`en_PH`/`en_CA` get 12-hour (`10am–3pm`), everything else (including unset and `C`/`POSIX`) gets 24-hour (`10:00–15:00`). ([#2899](max-sixty/worktrunk#2899), [#2911](max-sixty/worktrunk#2911))

- **`wt step prune` streams removals and never prompts mid-scan**: Prune now bundles integration, removability, and age checks into a single parallel pass and starts removing candidates as soon as they qualify, instead of batching the scan and acting at the end. Dirty / locked / primary worktrees drop out before the age check, so a young + dirty + integrated worktree no longer surfaces as `Skipped (younger than 1d)` — the `(younger than X)` message now fires only when the worktree would actually have been pruned. With `--yes`, every project command is auto-approved as before; without `--yes`, a candidate whose hooks include an unapproved project command is SKIPPED with `(approval required)` rather than aborting the scan with an inline prompt the streaming structure couldn't accommodate. The end-of-run hint enumerates the unapproved hook templates from the invoking worktree's config and emits one copy-pasteable `wt -C <path> remove` line per skipped candidate, annotating candidates whose own `.config/wt.toml` differs from the invoking worktree's. ([#2908](max-sixty/worktrunk#2908), [#2910](max-sixty/worktrunk#2910))

- **`wt step prune` default `--min-age` raised from 1h to 1d**: A worktree just created from the default branch looks "merged" because its branch still points at the same commit; a one-day floor keeps an unattended prune from sweeping it up before its owner starts work. Explicit `--min-age=0s` or any other value is unchanged. ([#2886](max-sixty/worktrunk#2886))

- **Legacy shell-wrapper deprecation warning**: Users who upgrade `wt` without restarting their shell still run the previous release's wrapper, which sets only `WORKTRUNK_DIRECTIVE_FILE` instead of the new split `WORKTRUNK_DIRECTIVE_CD_FILE` / `WORKTRUNK_DIRECTIVE_EXEC_FILE` pair. That fallback used to be silent; `wt` now emits a one-shot per-process warning hinting at `wt config shell install`. bash, zsh, fish, and PowerShell pick up the new wrapper on the next shell restart; nushell is the one shell where users must rerun `wt config shell install nu` because its wrapper is a static file. ([#2880](max-sixty/worktrunk#2880))

- **`-vv` no longer floods stderr; raw subprocess sink renamed to `subprocess.log`**: A `-vv` invocation used to spray ~15K lines of stderr per command, forcing a redirect to a file even though `trace.log` already mirrored most of it. The debug-level `log::*` pipeline now writes to `.git/wt/logs/trace.log` at `-vv`; Info-level records (hook output, template expansions, the `Tracing to …` pointer) stay on stderr at every verbosity level. The companion raw-subprocess-bytes file is renamed from `output.log` to `subprocess.log` — the prior name read as "stuff `wt` printed" but actually held uncapped multi-MB subprocess bodies (`git log -p`, patch-id pipelines). `RUST_LOG` is now honored at every verbosity level: `wt -v` and `wt -vv` previously hardcoded Info / Debug and silently dropped any `RUST_LOG` directive (`RUST_LOG=trace wt -vv` was capped at Debug, `RUST_LOG=worktrunk=trace wt -v` was ignored); all three levels now flow through one builder shape with `RUST_LOG` layered on top of the flag baseline. ([#2892](max-sixty/worktrunk#2892), [#2901](max-sixty/worktrunk#2901), [#2913](max-sixty/worktrunk#2913))

### Fixed

- **Data-safety across the worktree merge / remove / prune lifecycle**: Five TOCTOU and scoping fixes. `wt merge` and `wt remove` revalidate cleanliness and branch integration *after* `pre-remove` hooks run, so a hook (or concurrent process) that dirties the worktree or advances the branch can no longer trash the directory or trigger `git branch -D` against the stale pre-hook decision. The background-removal path does the same revalidation and fails closed for submodule worktrees on the fallback path instead of forcing. `wt step prune` runs its rename-failure fallback `git branch -d` synchronously under the write guard for non-current worktrees (no more race against live integration readers on `.git/config`), scopes hook approval to the worktrees it will actually remove (an unrelated unapproved hook can no longer abort a non-interactive prune), and prunes the stale metadata of detached worktrees whose directory was deleted outside Worktrunk. ([#2870](max-sixty/worktrunk#2870))

### Documentation

- **`-v` / `-vv` help and FAQ**: The `-v` help text is split out from its 150-character parenthetical, and `docs/content/faq.md` gains a "What does `-v` / `-vv` do?" section with a three-level table. ([#2913](max-sixty/worktrunk#2913))

- **Hook docs and `pre-start` docstring**: The `pre_create` field docstring in `HooksConfig` (user-visible via generated JSON schema) read "Commands to execute before worktree creation"; `pre-start` actually runs *after* worktree creation, blocking. Restored the correct wording. The `docs/content/extending.md` overview is reworked to read more cleanly: parallel three-paragraph intro for hooks / aliases / custom subcommands, fewer em-dashes, and the Reference section's table no longer duplicates content covered in prose. ([#2879](max-sixty/worktrunk#2879), [#2912](max-sixty/worktrunk#2912))

### Internal

- **Migrated logging from `env_logger` to `tracing-subscriber`**: A layered subscriber routes records structurally by target and verbosity. Existing `log::*` callers are bridged into `tracing` via `tracing_log::LogTracer`. `[wt-trace]` records emit as typed structured fields with a single formatter rendering the wire shape, so the grammar lives in one place instead of being duplicated across every emit site.

- **`UncommittedChanges` error renders dirty files in the canonical gutter**, matching `ConflictingChanges` and the project's `format_with_gutter()` convention. ([#2887](max-sixty/worktrunk#2887))

## Install worktrunk 0.54.0

### Install prebuilt binaries via shell script

```sh
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/max-sixty/worktrunk/releases/download/v0.54.0/worktrunk-installer.sh | sh && wt config shell install
```

### Install prebuilt binaries via powershell script

```sh
powershell -ExecutionPolicy Bypass -c "irm https://github.com/max-sixty/worktrunk/releases/download/v0.54.0/worktrunk-installer.ps1 | iex"; git-wt config shell install
```

### Install prebuilt binaries via Homebrew

```sh
brew install worktrunk && wt config shell install
```

## Download worktrunk 0.54.0

|  File  | Platform | Checksum |
|--------|----------|----------|
| [worktrunk-aarch64-apple-darwin.tar.xz](https://github.com/max-sixty/worktrunk/releases/download/v0.54.0/worktrunk-aarch64-apple-darwin.tar.xz) | Apple Silicon macOS | [checksum](https://github.com/max-sixty/worktrunk/releases/download/v0.54.0/worktrunk-aarch64-apple-darwin.tar.xz.sha256) |
| [worktrunk-x86_64-apple-darwin.tar.xz](https://github.com/max-sixty/worktrunk/releases/download/v0.54.0/worktrunk-x86_64-apple-darwin.tar.xz) | Intel macOS | [checksum](https://github.com/max-sixty/worktrunk/releases/download/v0.54.0/worktrunk-x86_64-apple-darwin.tar.xz.sha256) |
| [worktrunk-x86_64-pc-windows-msvc.zip](https://github.com/max-sixty/worktrunk/releases/download/v0.54.0/worktrunk-x86_64-pc-windows-msvc.zip) | x64 Windows | [checksum](https://github.com/max-sixty/worktrunk/releases/download/v0.54.0/worktrunk-x86_64-pc-windows-msvc.zip.sha256) |
| [worktrunk-aarch64-unknown-linux-musl.tar.xz](https://github.com/max-sixty/worktrunk/releases/download/v0.54.0/worktrunk-aarch64-unknown-linux-musl.tar.xz) | ARM64 MUSL Linux | [checksum](https://github.com/max-sixty/worktrunk/releases/download/v0.54.0/worktrunk-aarch64-unknown-linux-musl.tar.xz.sha256) |
| [worktrunk-x86_64-unknown-linux-musl.tar.xz](https://github.com/max-sixty/worktrunk/releases/download/v0.54.0/worktrunk-x86_64-unknown-linux-musl.tar.xz) | x64 MUSL Linux | [checksum](https://github.com/max-sixty/worktrunk/releases/download/v0.54.0/worktrunk-x86_64-unknown-linux-musl.tar.xz.sha256) |



### Install via Cargo

```sh
cargo install worktrunk && wt config shell install
```

### Install via Winget (Windows)

```sh
winget install max-sixty.worktrunk && git-wt config shell install
```

### Install via AUR (Arch Linux)

```sh
paru worktrunk-bin && wt config shell install
```
</pre>
  <p>View the full release notes at <a href="https://github.com/max-sixty/worktrunk/releases/tag/v0.54.0">https://github.com/max-sixty/worktrunk/releases/tag/v0.54.0</a>.</p>
</details>
<hr>

See merge request: Harmonybrew/homebrew-core!7938
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.

2 participants