]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lslogins: make journald last logs time stamps to honor --time-format
authorSami Kerola <kerolasa@iki.fi>
Fri, 12 Dec 2014 23:07:28 +0000 (23:07 +0000)
committerSami Kerola <kerolasa@iki.fi>
Fri, 19 Dec 2014 09:11:02 +0000 (09:11 +0000)
This makes by default the last logs to have year in output when necessary.

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

index f050595ea5ab5b92ea55ff6122039f9d7cee3102..85fd7c8346258bc5b8f2dfb3992f7a91be57509d 100644 (file)
@@ -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