]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journalctl: add --system/--user flags
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 4 Jun 2013 23:33:34 +0000 (19:33 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 10 Jun 2013 14:10:06 +0000 (10:10 -0400)
--user basically gives messages from your own systemd --user services.
--system basically gives messages from PID 1, kernel, and --system
services. Those two options are not exahustive, because a priviledged
user might be able to see messages from other users, and they will not
be shown with either or both of those flags.

man/journalctl.xml
shell-completion/bash/journalctl
shell-completion/systemd-zsh-completion.zsh
src/journal/journalctl.c

index d9ca0a6074d97f54683f049b22ed2da0cef0f9d8..66100816ae4070c4ce7bce35dc60da32ad733fb8 100644 (file)
                                 journal.</para></listitem>
                         </varlistentry>
 
+                        <varlistentry>
+                                <term><option>--system</option></term>
+                                <term><option>--user</option></term>
+
+                                <listitem><para>Show messages from
+                                system services and the kernel (with
+                                <option>--system</option>).  Show
+                                messages from service of current user
+                                (with <option>--user</option>).
+                                If neither is specified, show all
+                                messages that the user can see.
+                                </para></listitem>
+                        </varlistentry>
+
                         <varlistentry>
                                 <term><option>-D</option></term>
                                 <term><option>--directory=</option></term>
index 19362ae77b7bfd87936b3b31dc25c05ce7fe69da..5ab59c99404bb468c7761bcbb1bb4b1fa5a747d4 100644 (file)
@@ -38,6 +38,7 @@ _journalctl() {
         local field_vals= cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
         local -A OPTS=(
                 [STANDALONE]='-a --all --full
+                              --system --user
                               -b --this-boot --disk-usage -f --follow --header
                               -h --help -l --local --new-id128 -m --merge --no-pager
                               --no-tail -q --quiet --setup-keys --this-boot --verify
index 411646ea59f11d56e3f1522935b54ae74486683a..68628917239899f2db18d6e4ab45fd871fb27647 100644 (file)
@@ -71,6 +71,8 @@ _ctls()
                 '--since=[Start showing entries newer or of the specified date]:YYYY-MM-DD HH\:MM\:SS' \
                 '--until=[Stop showing entries older or of the specified date]:YYYY-MM-DD HH\:MM\:SS' \
                 {-c,--cursor=}'[Start showing entries from specified cursor]:cursors:_journal_fields __CURSORS' \
+                '--system[Show system and kernel messages]' \
+                '--user[Show messages from user services]' \
                 {-b,--this-boot}'[Show data only from current boot]' \
                 {-u,--unit=}'[Show data only from the specified unit]:units:_journal_fields _SYSTEMD_UNIT' \
                 '--user-unit[Show data only from the specified user session unit]:units:_journal_fields _SYSTEMD_USER_UNIT' \
index de972a17dbe0b385f44bee421f44d86a5623bbc2..f404e414f46f8d9b25c4fb0993f212aa3c786691 100644 (file)
@@ -86,6 +86,7 @@ static char **arg_user_units = NULL;
 static const char *arg_field = NULL;
 static bool arg_catalog = false;
 static bool arg_reverse = false;
+static int arg_journal_type = 0;
 static const char *arg_root = NULL;
 
 static enum {
@@ -105,6 +106,8 @@ static int help(void) {
         printf("%s [OPTIONS...] [MATCHES...]\n\n"
                "Query the journal.\n\n"
                "Flags:\n"
+               "     --system            Show only the system journal\n"
+               "     --user              Show only the user journal for current user\n"
                "     --since=DATE        Start showing entries newer or of the specified date\n"
                "     --until=DATE        Stop showing entries older or of the specified date\n"
                "  -c --cursor=CURSOR     Start showing entries from specified cursor\n"
@@ -158,6 +161,8 @@ static int parse_argv(int argc, char *argv[]) {
                 ARG_NO_PAGER,
                 ARG_NO_TAIL,
                 ARG_NEW_ID128,
+                ARG_USER,
+                ARG_SYSTEM,
                 ARG_ROOT,
                 ARG_HEADER,
                 ARG_FULL,
@@ -171,7 +176,7 @@ static int parse_argv(int argc, char *argv[]) {
                 ARG_USER_UNIT,
                 ARG_LIST_CATALOG,
                 ARG_DUMP_CATALOG,
-                ARG_UPDATE_CATALOG
+                ARG_UPDATE_CATALOG,
         };
 
         static const struct option options[] = {
@@ -190,6 +195,8 @@ static int parse_argv(int argc, char *argv[]) {
                 { "merge",        no_argument,       NULL, 'm'              },
                 { "this-boot",    no_argument,       NULL, 'b'              },
                 { "dmesg",        no_argument,       NULL, 'k'              },
+                { "system",       no_argument,       NULL, ARG_SYSTEM       },
+                { "user",         no_argument,       NULL, ARG_USER         },
                 { "directory",    required_argument, NULL, 'D'              },
                 { "root",         required_argument, NULL, ARG_ROOT         },
                 { "header",       no_argument,       NULL, ARG_HEADER       },
@@ -324,6 +331,14 @@ static int parse_argv(int argc, char *argv[]) {
                         arg_this_boot = arg_dmesg = true;
                         break;
 
+                case ARG_SYSTEM:
+                        arg_journal_type |= SD_JOURNAL_SYSTEM;
+                        break;
+
+                case ARG_USER:
+                        arg_journal_type |= SD_JOURNAL_CURRENT_USER;
+                        break;
+
                 case 'D':
                         arg_directory = optarg;
                         break;
@@ -1094,9 +1109,9 @@ int main(int argc, char *argv[]) {
         }
 
         if (arg_directory)
-                r = sd_journal_open_directory(&j, arg_directory, 0);
+                r = sd_journal_open_directory(&j, arg_directory, arg_journal_type);
         else
-                r = sd_journal_open(&j, arg_merge ? 0 : SD_JOURNAL_LOCAL_ONLY);
+                r = sd_journal_open(&j, !arg_merge*SD_JOURNAL_LOCAL_ONLY + arg_journal_type);
         if (r < 0) {
                 log_error("Failed to open journal: %s", strerror(-r));
                 return EXIT_FAILURE;