summaryrefslogtreecommitdiff
path: root/shared/nm-utils/nm-test-utils.h
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2017-08-06 12:10:06 +0200
committerThomas Haller <thaller@redhat.com>2017-08-12 16:02:11 +0200
commit80e585a65decaa862f321dd5b71f2caa6de49788 (patch)
treecba6431611345542316e2ad18ed5d308ea94b5fd /shared/nm-utils/nm-test-utils.h
parent1fcc3c8c39b79685a1da8e94cce8231de8252078 (diff)
downloadNetworkManager-80e585a65decaa862f321dd5b71f2caa6de49788.tar.gz
test: redirect glib logging to stdout
Default g_log() logs to stdout for INFO level and higher, but logs to stderr for DEBUG/TRACE. That is annoying, because especially when redirecting the streams, the messages get mixed up. Install a log handler and just print to stdout for the tests.
Diffstat (limited to 'shared/nm-utils/nm-test-utils.h')
-rw-r--r--shared/nm-utils/nm-test-utils.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/shared/nm-utils/nm-test-utils.h b/shared/nm-utils/nm-test-utils.h
index 66118fe9cf..f7a87aae82 100644
--- a/shared/nm-utils/nm-test-utils.h
+++ b/shared/nm-utils/nm-test-utils.h
@@ -283,6 +283,15 @@ nmtst_free (void)
}
static inline void
+_nmtst_log_handler (const gchar *log_domain,
+ GLogLevelFlags log_level,
+ const gchar *message,
+ gpointer user_data)
+{
+ g_print ("%s\n", message);
+}
+
+static inline void
__nmtst_init (int *argc, char ***argv, gboolean assert_logging, const char *log_level, const char *log_domains, gboolean *out_set_logging)
{
const char *nmtst_debug;
@@ -591,6 +600,11 @@ __nmtst_init (int *argc, char ***argv, gboolean assert_logging, const char *log_
g_assert_no_error (error);
}
#endif
+
+ g_log_set_handler (G_LOG_DOMAIN,
+ G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION,
+ _nmtst_log_handler,
+ NULL);
}
#ifndef _NMTST_INSIDE_CORE