diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2013-06-09 21:50:56 -0400 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2013-06-09 22:38:29 -0400 |
commit | a72b63536f1da3a97677bf38590f22a962e5fe98 (patch) | |
tree | 57c23b69a236457b8bd2bf16dd1538b8be626246 /src/journal | |
parent | 62220cf70e381f6e08390523e4696f7bc431f927 (diff) |
journalctl: fix verbose output when no logs are found
$ journalctl -o verbose _EXE=/quiet/binary -f
-- Logs begin at Sun 2013-03-17 17:28:22 EDT. --
Failed to get realtime timestamp: Cannot assign requested address
JOURNAL_FOREACH_DATA_RETVAL is added, which allows the caller
to get the return value from sd_journal_enumerate_data. I think
we might want to expose this macro like SD_JOURNAL_FOREACH_DATA,
but for now it is in journal-internal.h.
There's a change in behaviour for output_*, not only in
output_verbose, that errors in sd_j_enumerate_data are not silently
ignored anymore.
https://bugs.freedesktop.org/show_bug.cgi?id=56459
Diffstat (limited to 'src/journal')
-rw-r--r-- | src/journal/journal-internal.h | 3 | ||||
-rw-r--r-- | src/journal/journalctl.c | 11 |
2 files changed, 9 insertions, 5 deletions
diff --git a/src/journal/journal-internal.h b/src/journal/journal-internal.h index c7e585d810..f576a0073d 100644 --- a/src/journal/journal-internal.h +++ b/src/journal/journal-internal.h @@ -139,3 +139,6 @@ static inline void journal_closep(sd_journal **j) { } #define _cleanup_journal_close_ _cleanup_(journal_closep) + +#define JOURNAL_FOREACH_DATA_RETVAL(j, data, l, retval) \ + for (sd_journal_restart_data(j); ((retval) = sd_journal_enumerate_data((j), &(data), &(l))) > 0; ) diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c index eb79c4d853..de972a17db 100644 --- a/src/journal/journalctl.c +++ b/src/journal/journalctl.c @@ -1288,11 +1288,10 @@ int main(int argc, char *argv[]) { log_error("Failed to iterate through journal: %s", strerror(-r)); goto finish; } + if (r == 0) + break; } - if (r == 0) - break; - if (arg_until_set && !arg_reverse) { usec_t usec; @@ -1338,10 +1337,12 @@ int main(int argc, char *argv[]) { arg_catalog * OUTPUT_CATALOG; r = output_journal(stdout, j, arg_output, 0, flags); - if (r < 0 || ferror(stdout)) + need_seek = true; + if (r == -EADDRNOTAVAIL) + break; + else if (r < 0 || ferror(stdout)) goto finish; - need_seek = true; n_shown++; } |