mirror of
https://github.com/systemd/systemd.git
synced 2024-12-25 01:34:28 +03:00
journalctl,man: allow + only between terms
https://bugzilla.redhat.com/show_bug.cgi?id=1110712
This commit is contained in:
parent
be8f4a9fa7
commit
4e60294351
Notes:
Lennart Poettering
2014-08-19 21:20:00 +02:00
Backport: bugfix
@ -84,10 +84,11 @@
|
|||||||
field, then they are automatically matched as
|
field, then they are automatically matched as
|
||||||
alternatives, i.e. the resulting output will show
|
alternatives, i.e. the resulting output will show
|
||||||
entries matching any of the specified matches for the
|
entries matching any of the specified matches for the
|
||||||
same field. Finally, if the character
|
same field. Finally, the character
|
||||||
<literal>+</literal> appears as a separate word on the
|
<literal>+</literal> may appears as a separate word
|
||||||
command line, all matches before and after are combined
|
between other terms on the command line. This causes
|
||||||
in a disjunction (i.e. logical OR).</para>
|
all matches before and after to be combined in a
|
||||||
|
disjunction (i.e. logical OR).</para>
|
||||||
|
|
||||||
<para>As shortcuts for a few types of field/value
|
<para>As shortcuts for a few types of field/value
|
||||||
matches, file paths may be specified. If a file path
|
matches, file paths may be specified. If a file path
|
||||||
@ -98,11 +99,21 @@
|
|||||||
<literal>_KERNEL_DEVICE=</literal> match for the
|
<literal>_KERNEL_DEVICE=</literal> match for the
|
||||||
device.</para>
|
device.</para>
|
||||||
|
|
||||||
|
<para>Additional contraints may be added using options
|
||||||
|
<option>--boot</option>, <option>--unit=</option>,
|
||||||
|
etc, to futher limit what entries will be shown
|
||||||
|
(logical AND).</para>
|
||||||
|
|
||||||
<para>Output is interleaved from all accessible
|
<para>Output is interleaved from all accessible
|
||||||
journal files, whether they are rotated or currently
|
journal files, whether they are rotated or currently
|
||||||
being written, and regardless of whether they belong to the
|
being written, and regardless of whether they belong to the
|
||||||
system itself or are accessible user journals.</para>
|
system itself or are accessible user journals.</para>
|
||||||
|
|
||||||
|
<para>The set of journal files which will be used
|
||||||
|
can be modified using the <option>--user</option>,
|
||||||
|
<option>--system</option>, <option>--directory</option>,
|
||||||
|
and <option>--file</option> options, see below.</para>
|
||||||
|
|
||||||
<para>All users are granted access to their private
|
<para>All users are granted access to their private
|
||||||
per-user journals. However, by default, only root and
|
per-user journals. However, by default, only root and
|
||||||
users who are members of the <literal>systemd-journal</literal>
|
users who are members of the <literal>systemd-journal</literal>
|
||||||
|
@ -699,15 +699,20 @@ static int generate_new_id128(void) {
|
|||||||
|
|
||||||
static int add_matches(sd_journal *j, char **args) {
|
static int add_matches(sd_journal *j, char **args) {
|
||||||
char **i;
|
char **i;
|
||||||
|
bool have_term = false;
|
||||||
|
|
||||||
assert(j);
|
assert(j);
|
||||||
|
|
||||||
STRV_FOREACH(i, args) {
|
STRV_FOREACH(i, args) {
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (streq(*i, "+"))
|
if (streq(*i, "+")) {
|
||||||
|
if (!have_term)
|
||||||
|
break;
|
||||||
r = sd_journal_add_disjunction(j);
|
r = sd_journal_add_disjunction(j);
|
||||||
else if (path_is_absolute(*i)) {
|
have_term = false;
|
||||||
|
|
||||||
|
} else if (path_is_absolute(*i)) {
|
||||||
_cleanup_free_ char *p, *t = NULL, *t2 = NULL;
|
_cleanup_free_ char *p, *t = NULL, *t2 = NULL;
|
||||||
const char *path;
|
const char *path;
|
||||||
_cleanup_free_ char *interpreter = NULL;
|
_cleanup_free_ char *interpreter = NULL;
|
||||||
@ -756,8 +761,12 @@ static int add_matches(sd_journal *j, char **args) {
|
|||||||
r = sd_journal_add_match(j, t, 0);
|
r = sd_journal_add_match(j, t, 0);
|
||||||
if (t2)
|
if (t2)
|
||||||
r = sd_journal_add_match(j, t2, 0);
|
r = sd_journal_add_match(j, t2, 0);
|
||||||
} else
|
have_term = true;
|
||||||
|
|
||||||
|
} else {
|
||||||
r = sd_journal_add_match(j, *i, 0);
|
r = sd_journal_add_match(j, *i, 0);
|
||||||
|
have_term = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
log_error("Failed to add match '%s': %s", *i, strerror(-r));
|
log_error("Failed to add match '%s': %s", *i, strerror(-r));
|
||||||
@ -765,6 +774,11 @@ static int add_matches(sd_journal *j, char **args) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!strv_isempty(args) && !have_term) {
|
||||||
|
log_error("\"+\" can only be used between terms");
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user