diff options
author | Sami Kerola | 2014-12-13 00:07:28 +0100 |
---|---|---|
committer | Sami Kerola | 2014-12-19 10:11:02 +0100 |
commit | f838efeb67553490638cf589d3c304b152554dda (patch) | |
tree | a4d3a742880dc6a134408bac0a20e9d07f3b583e /login-utils/lslogins.c | |
parent | lslogins: allow changing password changed and expiration time formats (diff) | |
download | kernel-qcow2-util-linux-f838efeb67553490638cf589d3c304b152554dda.tar.gz kernel-qcow2-util-linux-f838efeb67553490638cf589d3c304b152554dda.tar.xz kernel-qcow2-util-linux-f838efeb67553490638cf589d3c304b152554dda.zip |
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 <kerolasa@iki.fi>
Diffstat (limited to 'login-utils/lslogins.c')
-rw-r--r-- | login-utils/lslogins.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/login-utils/lslogins.c b/login-utils/lslogins.c index f050595ea..85fd7c834 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 |