Repository navigation
parse-live: Filter traces like syslog live (-m, -v, -mi, -vi, -r, -ri), highlighting the matches - #54
Merged
Merged
Conversation
…tches `PyKdebugParser.line_filter` takes a `LineFilter` with pymobiledevice3's `syslog live` filters: `match` (all must be in the line), `invert_match` (none may be), their case-insensitive forms, and regexes (any must match). `formatted_traces` and `dict_traces` give only the traces whose printed line (time, process and event) it keeps, and colored lines get the matches bold and underlined, inside the colors too (`emphasize`). A dropped line is never colored, so a selective filter parses faster than none; the emphasized events are cached like their colors, so even a filter that keeps nearly every line costs ~20%. Without a filter, the output and speed are those of before.
…mi, -vi, -r and -ri The options and their help are the ones pymobiledevice3's parse-live takes (from `MATCH_HELP`). The regexes are -r/-ri rather than syslog's -e/-ei, which parse-live's --event already has. They match the printed line in --json too, and highlight in both color modes.
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.
parse-livegains pymobiledevice3syslog live's text filters, which highlight the matched parts (bold and underlined):-m/-mi: every one must match;-miignores case.-v/-vi: none may match;-viignores case.-r/-ri: any regex is enough;-riignores case.The regexes are
-r/-rirather than syslog's-e/-ei, becauseparse-livealready uses-efor--event.(Brackets mark the parts printed bold and underlined.)
The filter is library code,
PyKdebugParser.line_filter = LineFilter(...)(pykdebugparser.line_filter), with the option help inMATCH_HELP, so pymobiledevice3'sparse-livecan take the same options. Filters match the printed line (time, thread, process and event), and with--jsonthey match the line that would have been printed, as syslog's do.Pace
--bscwith rich colors on a recorded Mac trace underfindload (2.4M events):main-m connect(rare)-v find(-r 'open.*Library'-m open-m o(most lines)-mi FIND(nearly all lines)A dropped line is never colored, so a selective filter parses faster than no filter. A kept line's emphasized event is cached the way its colors already are. Live on this Mac,
-mi a(most lines kept) ran 15 s twice with 0 dropped and 0 skipped.No regressions
mainon recorded Mac and iPhone traces, colored and plain, with and without--show-tid(8 combinations, 0.9-1M lines each).main's lines filtered by a reference implementation. Colored lines equal the plain ones once their escape sequences are stripped.re.finditer's on 20,000 random lines.