]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lslogins: add space to systemd journal header and message
authorSami Kerola <kerolasa@iki.fi>
Sat, 13 Dec 2014 17:49:20 +0000 (17:49 +0000)
committerSami Kerola <kerolasa@iki.fi>
Fri, 19 Dec 2014 09:11:02 +0000 (09:11 +0000)
This commit changes journal messages in individual user printout the
following way.

Dec 13 16:02:05 systemd[324]:Time has been changed (old)
Dec 13 16:02:05 systemd[324]: Time has been changed (new)

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
login-utils/lslogins.c

index 5e1ef171c086c6232e0053c78481a237e5ec65f4..0c6a1fcbf43ca1f3660ff0722c7c0a97bbc656f2 100644 (file)
@@ -1058,7 +1058,7 @@ static void fill_table(const void *u, const VISIT which, const int depth __attri
 static void print_journal_tail(const char *journal_path, uid_t uid, size_t len, int time_mode)
 {
        sd_journal *j;
-       char *match, *buf;
+       char *match, *timestamp;
        uint64_t x;
        time_t t;
        const char *identifier, *pid, *message;
@@ -1088,21 +1088,18 @@ static void print_journal_tail(const char *journal_path, uid_t uid, size_t len,
 
                sd_journal_get_realtime_usec(j, &x);
                t = x / 1000000;
-               buf = make_time(time_mode, t);
-
-               fprintf(stdout, "%s", buf);
-
+               timestamp = make_time(time_mode, t);
+               /* Get rid of journal entry field identifiers */
                identifier = strchr(identifier, '=') + 1;
-               pid = strchr(pid, '=') + 1              ;
+               pid = strchr(pid, '=') + 1;
                message = strchr(message, '=') + 1;
 
-               fprintf(stdout, " %s", identifier);
-               fprintf(stdout, "[%s]:", pid);
-               fprintf(stdout, "%s\n", message);
+               fprintf(stdout, "%s %s[%s]: %s\n", timestamp, identifier, pid,
+                       message);
+               free(timestamp);
        } while (sd_journal_next(j));
 
 done:
-       free(buf);
        free(match);
        sd_journal_flush_matches(j);
        sd_journal_close(j);