Make diagnostic logging safe and bounded#157
Open
camjac251 wants to merge 3 commits into
Open
Conversation
Diagnostic output previously recorded arguments and paths, could fail Git operations on I/O errors, and grew without a limit. Emit metadata-only records, cap and rotate the log under a non-blocking process mutex, and treat logging failures or contention as best-effort drops.
Clarify that wrapper diagnostics are opt-in and independent from Fork's verbose Git output. Document the metadata contract, size bounds, dropped records under contention, and the intended troubleshooting workflow.
Use the direct string length and pass path and argument values in the forms expected by the command APIs. This keeps the new diagnostics code from adding warnings to repositories that enforce a clean Clippy run.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Problem
The existing opt-in log can contain command arguments, paths, environment-derived
values, and operating-system error text. It is unbounded, and an I/O failure can
interrupt the Git operation that logging is meant to diagnose. Concurrent wrapper
processes can also race during rotation and append.
Implementation
Diagnostic records now contain only controlled event names, counts, routing
targets, timestamps, process IDs, exit status, durations, and
io::ErrorKind.They do not serialize arguments, repository paths, environment values, OS error
messages, or credentials.
A non-blocking named mutex covers the complete size-check, rotation, and append
sequence. Contended records are dropped instead of delaying Git. Each line is
assembled before one
write_allcall, and all logging failures are ignored.Verification
complete logs and preserved rotated history
unrelated host-shell fixture excluded
cargo build --release --target x86_64-pc-windows-gnucargo fmt --all -- --checkcargo clippy --target x86_64-pc-windows-gnu --bin wslgit --testsgit diff --check