summaryrefslogtreecommitdiffstats
path: root/login-utils/lslogins.c
diff options
context:
space:
mode:
authorSami Kerola2014-12-13 18:49:20 +0100
committerSami Kerola2014-12-19 10:11:02 +0100
commit77006d95db0b06cda65d82360bbf1cce4a775094 (patch)
tree484da805d0e8498e940eca6f03e567122c667b44 /login-utils/lslogins.c
parentlslogins: reject unknown time format arguments (diff)
downloadkernel-qcow2-util-linux-77006d95db0b06cda65d82360bbf1cce4a775094.tar.gz
kernel-qcow2-util-linux-77006d95db0b06cda65d82360bbf1cce4a775094.tar.xz
kernel-qcow2-util-linux-77006d95db0b06cda65d82360bbf1cce4a775094.zip
lslogins: add space to systemd journal header and message
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>
Diffstat (limited to 'login-utils/lslogins.c')
-rw-r--r--login-utils/lslogins.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/login-utils/lslogins.c b/login-utils/lslogins.c
index 5e1ef171c..0c6a1fcbf 100644
--- a/login-utils/lslogins.c
+++ b/login-utils/lslogins.c
@@ -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);