[glib] gmessages: Flush output stream after logging messages



commit 5fba62adecbb9e7d65966460c16eb6c18d04dbe8
Author: Benjamin Berg <bberg redhat com>
Date:   Mon Jan 15 17:31:21 2018 +0100

    gmessages: Flush output stream after logging messages
    
    When debug output is enabled then certain messages will be logged to
    stdout. stdout however is block buffered by default when it isn't going
    to a TTY meaning that debug logging will not be flushed out properly
    when it is being redirected. One example of this happening may be tests
    that rely on parsing g_debug messages.
    
    Adding an explicit fflush ensures all log messages will reach the output.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=792432

 glib/gmessages.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
---
diff --git a/glib/gmessages.c b/glib/gmessages.c
index 8c78568..dfae4df 100644
--- a/glib/gmessages.c
+++ b/glib/gmessages.c
@@ -2556,6 +2556,7 @@ g_log_writer_standard_streams (GLogLevelFlags   log_level,
   out = g_log_writer_format_fields (log_level, fields, n_fields,
                                     g_log_writer_supports_color (fileno (stream)));
   _g_fprintf (stream, "%s\n", out);
+  fflush (stream);
   g_free (out);
 
   return G_LOG_WRITER_HANDLED;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]