Commit 8c92699
Make trace command logging truncation configurable via
Trace-level `Executing ...` lines currently truncate command arguments
at a hardcoded 120 characters, which hides critical details when
debugging hooks (notably `docker_image` entrypoint/args). This change
introduces a configurable truncate limit while preserving existing
default behavior.
- **Config surface: new env var**
- Added `PREK_LOG_TRUNCATE_LIMIT` to `prek-consts` (`EnvVars`).
- **Runtime behavior in command logging**
- Updated `Cmd` display formatting in `crates/prek/src/process.rs` to
read truncation limit from `PREK_LOG_TRUNCATE_LIMIT`.
- Cached the resolved truncate limit with `LazyLock` so env parsing
happens once.
- Kept default at `120` when unset/invalid.
- Treated `0` as invalid and fallback to default to avoid degenerate
output.
- **Documentation**
- Added `PREK_LOG_TRUNCATE_LIMIT` to `docs/configuration.md` under
environment variables, including default and intent.
- **Focused unit coverage**
- Added tests for:
- env var value parsing (valid/invalid/zero),
- env-based resolution behavior,
- cached-limit behavior via `LazyLock`,
- env restoration guard to avoid cross-test env leakage.
```rust
const DEFAULT_COMMAND_LOG_TRUNCATE_LIMIT: usize = 120;
static COMMAND_LOG_TRUNCATE_LIMIT: LazyLock<usize> =
LazyLock::new(command_log_truncate_limit_from_env);
fn command_log_truncate_limit() -> usize {
*COMMAND_LOG_TRUNCATE_LIMIT
}
```
<!-- START COPILOT ORIGINAL PROMPT -->
<details>
<summary>Original prompt</summary>
>
> ----
>
> *This section details on the original issue you should resolve*
>
> <issue_title>Do not truncate trace run executions</issue_title>
> <issue_description>### Summary
>
> I was trying to debug a docker_image hook execution and was delighted
to note the --log-file option.
>
> However, turns out that the "Executing" TRACE run lines are truncated
with `[...]` before showing the part I'm actually interested in (a case
of tweaking entrypoints and arguments).
>
> I'd suggest not truncating these lines in the trace log at all, or
providing an option not to truncate.
>
> ### Willing to submit a PR?
>
> - [ ] Yes — I’m willing to open a PR to fix this.
>
> ### Platform
>
> Ubuntu 25.10 amd64
>
> ### Version
>
> 0.3.2
>
> ### .pre-commit-config.yaml
>
> N/A
>
> ### Log file
>
> ```
> 2026-02-20T10:17:47.223740Z TRACE run{hook_id=...
language=docker_image}: Executing `cd ... && docker run --rm --tty
--user 1000:1000 --init --volume ...:/src:rw,Z --workdir /src
--entrypoint ... --network [...]`
> ```</issue_description>
>
> <agent_instructions>Add a new env var to prek-consts, controlling the
command line log truncate limit in process.rs, current it is hardcoded
to 120. Document it in docs/configuration.md env vars
section.</agent_instructions>
>
> ## Comments on the Issue (you are @copilot in this section)
>
> <comments>
> </comments>
>
</details>
<!-- START COPILOT CODING AGENT SUFFIX -->
- Fixes #1678
<!-- START COPILOT CODING AGENT TIPS -->
---
🔒 GitHub Advanced Security automatically protects Copilot coding agent
pull requests. You can protect all pull requests by enabling Advanced
Security for your repositories. [Learn more about Advanced
Security.](https://gh.io/cca-advanced-security)
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: j178 <10510431+j178@users.noreply.github.com>PREK_LOG_TRUNCATE_LIMIT (#1679)1 parent 4872215 commit 8c92699
File tree
3 files changed
+14
-1
lines changed- crates
- prek-consts/src
- prek/src
- docs
3 files changed
+14
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
| 36 | + | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
39 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
40 | 50 | | |
41 | 51 | | |
42 | 52 | | |
| |||
495 | 505 | | |
496 | 506 | | |
497 | 507 | | |
498 | | - | |
| 508 | + | |
499 | 509 | | |
500 | 510 | | |
501 | 511 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1355 | 1355 | | |
1356 | 1356 | | |
1357 | 1357 | | |
| 1358 | + | |
| 1359 | + | |
1358 | 1360 | | |
1359 | 1361 | | |
1360 | 1362 | | |
| |||
0 commit comments