summaryrefslogtreecommitdiff
path: root/src/journal/journalctl.c
diff options
context:
space:
mode:
authorHarald Hoyer <harald@redhat.com>2013-04-11 15:27:55 +0200
committerHarald Hoyer <harald@redhat.com>2013-04-17 09:15:23 +0200
commitcd34b3c6670df8a3fd49179131fe762b2dd86b01 (patch)
tree60dc6d2658200e41ae0c0e9a6510f78e6d3d19ee /src/journal/journalctl.c
parent003ac9d0318ce28e0b29af5440c9f28f884da04c (diff)
journal: add one more level on top with AND
When using "-p" and "-b" in combination with "-u", the output is not what you would expect. The reason is the sd_journal_add_disjunction() call in add_matches_for_unit() and add_matches_for_user_unit(), which adds two ORs without taking the other conditions to every OR. Adding another level on top with AND and sd_journal_add_conjunction() solves the problem. Output before: $ journalctl -o short-monotonic -ab -p 0 -u sshd.service -- Reboot -- [ 3.216305] lenovo systemd[1]: Starting OpenSSH server daemon... -- Reboot -- [ 3.168666] lenovo systemd[1]: Starting OpenSSH server daemon... [ 3.169639] lenovo systemd[1]: Started OpenSSH server daemon. [36285.635389] lenovo systemd[1]: Stopped OpenSSH server daemon. -- Reboot -- [ 10.838657] lenovo systemd[1]: Starting OpenSSH server daemon... [ 10.913698] lenovo systemd[1]: Started OpenSSH server daemon. [ 6881.035183] lenovo systemd[1]: Stopped OpenSSH server daemon. -- Reboot -- [ 6.636228] lenovo systemd[1]: Starting OpenSSH server daemon... [ 6.662573] lenovo systemd[1]: Started OpenSSH server daemon. [ 6.681148] lenovo sshd[397]: Server listening on 0.0.0.0 port 22. [ 6.681379] lenovo sshd[397]: Server listening on :: port 22. As we see, the output is from _every_ boot and priority 0 is not taken into account. Output after patch: $ journalctl -o short-monotonic -ab -p 0 -u sshd.service -- Logs begin at Sun 2013-02-24 20:54:44 CET, end at Tue 2013-03-19 14:58:21 CET. -- Increasing the priority: $ journalctl -o short-monotonic -ab -p 6 -u sshd.service -- Logs begin at Sun 2013-02-24 20:54:44 CET, end at Tue 2013-03-19 14:59:12 CET. -- [ 6.636228] lenovo systemd[1]: Starting OpenSSH server daemon... [ 6.662573] lenovo systemd[1]: Started OpenSSH server daemon. [ 6.681148] lenovo sshd[397]: Server listening on 0.0.0.0 port 22. [ 6.681379] lenovo sshd[397]: Server listening on :: port 22.
Diffstat (limited to 'src/journal/journalctl.c')
-rw-r--r--src/journal/journalctl.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c
index c9b2abecea..2ebac405c2 100644
--- a/src/journal/journalctl.c
+++ b/src/journal/journalctl.c
@@ -604,6 +604,10 @@ static int add_this_boot(sd_journal *j) {
return r;
}
+ r = sd_journal_add_conjunction(j);
+ if (r < 0)
+ return r;
+
return 0;
}
@@ -627,13 +631,16 @@ static int add_unit(sd_journal *j) {
if (r < 0)
return r;
+ r = sd_journal_add_conjunction(j);
+ if (r < 0)
+ return r;
+
return 0;
}
static int add_priorities(sd_journal *j) {
char match[] = "PRIORITY=0";
int i, r;
-
assert(j);
if (arg_priorities == 0xFF)
@@ -650,6 +657,10 @@ static int add_priorities(sd_journal *j) {
}
}
+ r = sd_journal_add_conjunction(j);
+ if (r < 0)
+ return r;
+
return 0;
}
@@ -1106,11 +1117,11 @@ int main(int argc, char *argv[]) {
if (r < 0)
return EXIT_FAILURE;
- r = add_matches(j, argv + optind);
+ r = add_priorities(j);
if (r < 0)
return EXIT_FAILURE;
- r = add_priorities(j);
+ r = add_matches(j, argv + optind);
if (r < 0)
return EXIT_FAILURE;