summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Berg <bberg@redhat.com>2018-01-11 15:55:32 +0100
committerBenjamin Berg <bberg@redhat.com>2018-01-15 17:15:17 +0100
commitdee9a77f889c8f539bdfab77d9982e9358b8016d (patch)
treec99568ac52920d9797e11ca4fa177a6358895481
parent9ad0468bba7743d9b5cd6c41b0bca7d2101af06a (diff)
downloadgnome-settings-daemon-dee9a77f889c8f539bdfab77d9982e9358b8016d.tar.gz
common: Work around output buffering for g_debug
During testing debug output is enabled using --verbose. Unfortunately the default logging handler in GLib is not flushing the utput stream for each log message. In addition, the default buffering for stdout seems to be block based (not line based) if stdout is not a TTY. This causes the log message to get stuck in the buffer and the tests cannot read them. See also https://bugzilla.gnome.org/show_bug.cgi?id=792432 https://bugzilla.gnome.org/show_bug.cgi?id=792210
-rw-r--r--plugins/common/daemon-skeleton-gtk.h12
-rw-r--r--plugins/common/daemon-skeleton.h12
2 files changed, 22 insertions, 2 deletions
diff --git a/plugins/common/daemon-skeleton-gtk.h b/plugins/common/daemon-skeleton-gtk.h
index 27aade6c..2194b3d6 100644
--- a/plugins/common/daemon-skeleton-gtk.h
+++ b/plugins/common/daemon-skeleton-gtk.h
@@ -212,8 +212,18 @@ main (int argc, char **argv)
set_empty_gtk_theme (FALSE);
- if (verbose)
+ if (verbose) {
g_setenv ("G_MESSAGES_DEBUG", "all", TRUE);
+ /* Work around GLib not flushing the output for us by explicitly
+ * setting buffering to a sane behaviour. This is important
+ * during testing when the output is not going to a TTY and
+ * we are reading messages from g_debug on stdout.
+ *
+ * See also
+ * https://bugzilla.gnome.org/show_bug.cgi?id=792432
+ */
+ setlinebuf (stdout);
+ }
if (timeout > 0) {
guint id;
diff --git a/plugins/common/daemon-skeleton.h b/plugins/common/daemon-skeleton.h
index e4641fcc..367ac1ec 100644
--- a/plugins/common/daemon-skeleton.h
+++ b/plugins/common/daemon-skeleton.h
@@ -185,8 +185,18 @@ main (int argc, char **argv)
loop = g_main_loop_new (NULL, FALSE);
- if (verbose)
+ if (verbose) {
g_setenv ("G_MESSAGES_DEBUG", "all", TRUE);
+ /* Work around GLib not flushing the output for us by explicitly
+ * setting buffering to a sane behaviour. This is important
+ * during testing when the output is not going to a TTY and
+ * we are reading messages from g_debug on stdout.
+ *
+ * See also
+ * https://bugzilla.gnome.org/show_bug.cgi?id=792432
+ */
+ setlinebuf (stdout);
+ }
if (timeout > 0) {
guint id;