From: Sami Kerola Date: Sat, 13 Dec 2014 17:49:20 +0000 (+0000) Subject: lslogins: add space to systemd journal header and message X-Git-Tag: v2.26-rc1~112^2~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=77006d95db0b06cda65d82360bbf1cce4a775094;p=thirdparty%2Futil-linux.git 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 --- diff --git a/login-utils/lslogins.c b/login-utils/lslogins.c index 5e1ef171c0..0c6a1fcbf4 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);