From 0e4a4f56bebc94a99134d79c5e1148aa787fc4dc Mon Sep 17 00:00:00 2001 From: Arian van Putten Date: Mon, 12 Aug 2019 19:36:56 +0200 Subject: journalctl: Make journalctl --user-unit= match on _SYSTEMD_USER_SLICE journalctl --unit= already did this, and allows you to tail all the logs for a certain slice easily. It seemed only natural to make --user-unit behave in a similar way. The _SYSTEMD_USER_SLICE field was not documented as being added by journald, so I have added that to the documentation too. Furthermore, I have documented the existing behaviour of --unit= and the new behaviour of --user-unit= The behaviour was actually not documented before, so I am also OK with removing the match for the --unit= command instead. The user would then have to manually provide _SYSTEMD_SLICE= filter to journalctl in both cases. Both options work for me. --- man/journalctl.xml | 13 +++++++++++-- man/systemd.journal-fields.xml | 1 + src/journal/journalctl.c | 3 ++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/man/journalctl.xml b/man/journalctl.xml index 0ecab521fa0..f6703b06d65 100644 --- a/man/journalctl.xml +++ b/man/journalctl.xml @@ -544,7 +544,12 @@ the unit (_SYSTEMD_UNIT=UNIT), along with additional matches for messages from systemd and - messages about coredumps for the specified unit. + messages about coredumps for the specified unit. A match + is also added for _SYSTEMD_SLICE=UNIT, + such that if the provided UNIT is a + systemd.slice5 + unit, all logs of the children of the slice will be logged. + This parameter can be specified multiple times. @@ -558,7 +563,11 @@ (_SYSTEMD_USER_UNIT= and _UID=) and additional matches for messages from session systemd and messages about coredumps for the - specified unit. + specified unit. A match + is also added for _SYSTEMD_USER_SLICE=UNIT, + such that if the provided UNIT is a + systemd.slice5 + unit, all logs of the children of the unit will be logged. This parameter can be specified multiple times. diff --git a/man/systemd.journal-fields.xml b/man/systemd.journal-fields.xml index fa374bf0f80..c11ec050e5a 100644 --- a/man/systemd.journal-fields.xml +++ b/man/systemd.journal-fields.xml @@ -188,6 +188,7 @@ _SYSTEMD_SLICE= _SYSTEMD_UNIT= _SYSTEMD_USER_UNIT= + _SYSTEMD_USER_SLICE= _SYSTEMD_SESSION= _SYSTEMD_OWNER_UID= diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c index 764b3c217e3..6d6bb1cf63c 100644 --- a/src/journal/journalctl.c +++ b/src/journal/journalctl.c @@ -1539,7 +1539,8 @@ static int get_possible_units( "_SYSTEMD_USER_UNIT\0" \ "USER_UNIT\0" \ "COREDUMP_USER_UNIT\0" \ - "OBJECT_SYSTEMD_USER_UNIT\0" + "OBJECT_SYSTEMD_USER_UNIT\0" \ + "_SYSTEMD_USER_SLICE\0" static int add_units(sd_journal *j) { _cleanup_strv_free_ char **patterns = NULL; -- cgit v1.2.3-59-g8ed1b