[systemd-devel] [PATCH 1/2] journal: add one more level on top with AND

Harald Hoyer harald.hoyer at gmail.com
Wed Apr 17 00:19:35 PDT 2013


Am 12.04.2013 09:29, schrieb harald at redhat.com:
> From: Harald Hoyer <harald at redhat.com>
> 
> 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.
> ---
>  src/journal/journal-internal.h   |  2 +-
>  src/journal/journalctl.c         | 17 +++++++--
>  src/journal/sd-journal.c         | 80 ++++++++++++++++++++++++++--------------
>  src/journal/test-journal-match.c | 16 +++++++-
>  src/systemd/sd-journal.h         |  1 +
>  5 files changed, 83 insertions(+), 33 deletions(-)
> 

pushed



More information about the systemd-devel mailing list