]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journalctl: Make journalctl --user-unit= match on _SYSTEMD_USER_SLICE
authorArian van Putten <arian.vanputten@gmail.com>
Mon, 12 Aug 2019 17:36:56 +0000 (19:36 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 22 Aug 2019 11:39:54 +0000 (13:39 +0200)
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
man/systemd.journal-fields.xml
src/journal/journalctl.c

index 0ecab521fa0aae8f18f6e16db126ed7e1a217465..f6703b06d65c9f7b7cafec725d9132ba0fab6221 100644 (file)
         the unit
         (<literal>_SYSTEMD_UNIT=<replaceable>UNIT</replaceable></literal>),
         along with additional matches for messages from systemd and
-        messages about coredumps for the specified unit.</para>
+        messages about coredumps for the specified unit. A match
+        is also added for <literal>_SYSTEMD_SLICE=<replaceable>UNIT</replaceable></literal>,
+        such that if the provided <replaceable>UNIT</replaceable> is a
+        <citerefentry><refentrytitle>systemd.slice</refentrytitle><manvolnum>5</manvolnum></citerefentry>
+        unit, all logs of the children of the slice will be logged.
+       </para>
 
         <para>This parameter can be specified multiple times.</para>
         </listitem>
         (<literal>_SYSTEMD_USER_UNIT=</literal> and
         <literal>_UID=</literal>) and additional matches for messages
         from session systemd and messages about coredumps for the
-        specified unit.</para>
+        specified unit. A match
+        is also added for <literal>_SYSTEMD_USER_SLICE=<replaceable>UNIT</replaceable></literal>,
+        such that if the provided <replaceable>UNIT</replaceable> is a
+        <citerefentry><refentrytitle>systemd.slice</refentrytitle><manvolnum>5</manvolnum></citerefentry>
+        unit, all logs of the children of the unit will be logged.</para>
 
         <para>This parameter can be specified multiple times.</para>
         </listitem>
index fa374bf0f804d1cdc487a8fed111cd00e5c9e274..c11ec050e5ae9323bf42a8c24bd8b6527f31ecf7 100644 (file)
         <term><varname>_SYSTEMD_SLICE=</varname></term>
         <term><varname>_SYSTEMD_UNIT=</varname></term>
         <term><varname>_SYSTEMD_USER_UNIT=</varname></term>
+        <term><varname>_SYSTEMD_USER_SLICE=</varname></term>
         <term><varname>_SYSTEMD_SESSION=</varname></term>
         <term><varname>_SYSTEMD_OWNER_UID=</varname></term>
 
index 764b3c217e3227f8802692b321538b85ae4d52e7..6d6bb1cf63c32bd47117373ad24c602c564d73f5 100644 (file)
@@ -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;