chiark / gitweb /
shared: logs-show: fflush after each output type
authorBrandon Philips <brandon@ifup.org>
Tue, 4 Sep 2012 01:37:46 +0000 (18:37 -0700)
committerLennart Poettering <lennart@poettering.net>
Tue, 4 Sep 2012 02:16:20 +0000 (19:16 -0700)
journalctl -f redirected to a pipe or file wasn't working for some
output formats but was working for json. It turns out only json was
doing an fflush.

Make all output formats flush.

src/shared/logs-show.c

index 99407c9c1d550bcee2712fe65e0d6cb9df9cb703..67b20563dffae74ce1b0cb74d09853426508a80e 100644 (file)
@@ -521,7 +521,6 @@ static int output_json(sd_journal *j, unsigned line,
         }
 
         fputs("\n}", stdout);
-        fflush(stdout);
 
         return 0;
 }
@@ -560,13 +559,16 @@ static int (*output_funcs[_OUTPUT_MODE_MAX])(sd_journal*j, unsigned line,
 
 int output_journal(sd_journal *j, OutputMode mode, unsigned line,
                    unsigned n_columns, OutputFlags flags) {
+        int ret;
         assert(mode >= 0);
         assert(mode < _OUTPUT_MODE_MAX);
 
         if (n_columns <= 0)
                 n_columns = columns();
 
-        return output_funcs[mode](j, line, n_columns, flags);
+        ret = output_funcs[mode](j, line, n_columns, flags);
+        fflush(stdout);
+        return ret;
 }
 
 int show_journal_by_unit(