Repository navigation
feat: add nyanpasu-log-preview for bounded payload logs - #206
Merged
Merged
Conversation
Logging an image, a profile or a script with Debug prints every byte: a widget logo alone becomes about a megabyte of text per line. The new crate formats a payload as its length, CRC-32 and a configurable number of bytes from each end, through both Display and Debug. It is a separate path crate that depends only on crc32fast, so the statistic widget's protocol can use it without pulling in Tokio. nyanpasu-utils re-exports it as log_preview.
parse_check_output was instrumented without skipping its argument, so a failed config check recorded the core's whole stdout as a span field. It now records the output's length, CRC-32 and ends.
Changed Files
|
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
Logging an image, a profile or a script with
Debugprints every byte of it. In the app, a statistic widget's image logo alone becomes about a megabyte of text per log line.nyanpasu-log-preview(new crate inlog-preview/): formats a payload as its length, CRC-32 and a configurable number of bytes from each end.bytes(&[u8])writes the ends in hex;text(&str)writes them as escaped strings and never splits a character..edge(n)sets how many bytes each end shows (default 8). A payload no longer than both ends is shown whole.DisplayandDebugare the same, so it fits both%and?fields intracing.It is a separate path crate that depends only on
crc32fast, so the widget protocol (used by the Tokio-free widget process) can use it without pulling in Tokio. It is not a workspace member, which keeps this repository free of a nested workspace; inside nyanpasu-runtime it becomes a workspace member automatically.nyanpasu-utilsre-exports it aslog_preview.parse_check_outputwas instrumented without skipping its argument, so a failed config check recorded the core's whole stdout as a span field. It now records a preview. Only the legacyCoreInstancecalls it, so no current app or service path reaches it.Notes
Cargo.lockgainscrc32fastand the new crate. Cargo also re-resolved a fewwindows-sys 0.59references to0.61; both satisfy the declared ranges.cargo packagewould need a version on the new path dependency. The crate is already unpublishable because of the git ProcessKit dependency, so no version was added.Test plan
cargo test -p nyanpasu-log-preview: 7 unit tests and 1 doctest. They cover short payloads, both ends, zero andusize::MAXedges, exactly two edges, character boundaries, and Debug = Display.cargo clippy -p nyanpasu-utils --all-features --all-targets: no new warnings. Theprocess/engine.rswarning was already there.Consumers: libnyanpasu/nyanpasu-runtime#458 (pin bump) and libnyanpasu/clash-nyanpasu#5941 (app log points).