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.
This commit is contained in:
Thomas Haller 2017-08-06 12:10:06 +02:00
parent 1fcc3c8c39
commit 80e585a65d

View file

@ -282,6 +282,15 @@ nmtst_free (void)
memset (&__nmtst_internal, 0, sizeof (__nmtst_internal));
}
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)
{
@ -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