[WIP] journal: support match negation#12592
Conversation
7e49208 to
bad6229
Compare
As a pretty common use case is to filter a particular service from the journactl output, let's add a NOT "operator" to the matching machinery. TODO: description, examples
bad6229 to
48010ef
Compare
dnicolodi
left a comment
There was a problem hiding this comment.
The ~ prefix is also not optimal because it expands to the home directory of the user whose user name is the string that follows. Thus your proposed syntax works without quoting only as long as there are not clashes between user names and journal field names.
Hah, that completely slipped my mind, thank you. I need to take a closer look at this, especially after letting this PR lay dormant for more than a half an year. |
|
@mrc0mmand update? |
|
So, the journal file format actionally contains a bisection table (i.e. a strictly ordered array) to find all entry records for a specific data record. i.e. for each assignment as in FOO=BAR (i.e. each "data record") we actually have a list of entry records by their offset that contain them. We can use this to speed things up a bit, i.e. we don't actually have to go to an entry record to check if it lacks a specific data record. We instead can go to just go to the data record that shall not match, and then just check if the offset of the next potentially matching entry is in there. or in other words: figure out the offset of the next potential entry, check it against any of the negation data record entry arrays, and skip them immediately if they appear there. |
To get myself familiar further with the systemd codebase (and to fix an issue which has been nagging me for a while), I implemented (or at least tried to) a fix for #2720.
First of all, this is just a (working, so far) mockup, as I'd like to get a feedback if this is even the right approach.
To avoid collisions with bash operators and such (i.e. using
!or-for negation) I chose~as a prefix for a field user wants to NOT match.For example:
journalctl -b ~MESSAGE="this is sparta"shows all messages for this boot which are not "this is sparta".
TODO: tests