From: Sami Kerola Date: Fri, 12 Dec 2014 23:07:28 +0000 (+0000) Subject: lslogins: make journald last logs time stamps to honor --time-format X-Git-Tag: v2.26-rc1~112^2~16 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f838efeb67553490638cf589d3c304b152554dda;p=thirdparty%2Futil-linux.git lslogins: make journald last logs time stamps to honor --time-format This makes by default the last logs to have year in output when necessary. Signed-off-by: Sami Kerola --- diff --git a/login-utils/lslogins.c b/login-utils/lslogins.c index f050595ea5..85fd7c8346 100644 --- a/login-utils/lslogins.c +++ b/login-utils/lslogins.c @@ -1055,7 +1055,7 @@ static void fill_table(const void *u, const VISIT which, const int depth __attri return; } #ifdef HAVE_LIBSYSTEMD -static void print_journal_tail(const char *journal_path, uid_t uid, size_t len) +static void print_journal_tail(const char *journal_path, uid_t uid, size_t len, int time_mode) { sd_journal *j; char *match, *buf; @@ -1069,7 +1069,6 @@ static void print_journal_tail(const char *journal_path, uid_t uid, size_t len) else sd_journal_open(&j, SD_JOURNAL_LOCAL_ONLY); - buf = xmalloc(sizeof(char) * 16); xasprintf(&match, "_UID=%d", uid); sd_journal_add_match(j, match, 0); @@ -1089,7 +1088,7 @@ 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; - strftime(buf, 16, "%b %d %H:%M:%S", localtime(&t)); + buf = make_time(time_mode, t); fprintf(stdout, "%s", buf); @@ -1148,7 +1147,7 @@ static int print_user_table(struct lslogins_control *ctl) print_pretty(tb); #ifdef HAVE_LIBSYSTEMD fprintf(stdout, _("\nLast logs:\n")); - print_journal_tail(ctl->journal_path, ctl->uid, 3); + print_journal_tail(ctl->journal_path, ctl->uid, 3, ctl->time_mode); fputc('\n', stdout); #endif } else