diff options
author | Philip Withnall <withnall@endlessm.com> | 2018-08-14 16:04:47 +0100 |
---|---|---|
committer | Philip Withnall <withnall@endlessm.com> | 2018-08-16 18:59:07 +0100 |
commit | fc6852c47a65dfadf415a09706e3dadf97be5ec0 (patch) | |
tree | 74c085e792eac371d9ac7c5251b828586b451ecb /tests/client.c | |
parent | a8dcd4f0decf78afdd22caaaad4ac746e075c3b0 (diff) | |
download | dconf-fc6852c47a65dfadf415a09706e3dadf97be5ec0.tar.gz |
tests: Port log message handling in tests to use structured logging
Otherwise the tests fail now that we’re compiling with
G_LOG_USE_STRUCTURED.
Signed-off-by: Philip Withnall <withnall@endlessm.com>
Diffstat (limited to 'tests/client.c')
-rw-r--r-- | tests/client.c | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/tests/client.c b/tests/client.c index 6390438..4727e0c 100644 --- a/tests/client.c +++ b/tests/client.c @@ -86,28 +86,22 @@ fail_one_call (void) g_error_free (error); } -static void -log_handler (const gchar *log_domain, - GLogLevelFlags log_level, - const gchar *message, - gpointer user_data) +static GLogWriterOutput +log_writer_cb (GLogLevelFlags log_level, + const GLogField *fields, + gsize n_fields, + gpointer user_data) { - if (strstr (message, "--expected error from testcase--")) - return; - - g_log_default_handler (log_domain, log_level, message, user_data); -} + gsize i; -static gboolean -fatal_log_handler (const gchar *log_domain, - GLogLevelFlags log_level, - const gchar *message, - gpointer user_data) -{ - if (strstr (message, "--expected error from testcase--")) - return FALSE; + for (i = 0; i < n_fields; i++) + { + if (g_strcmp0 (fields[i].key, "MESSAGE") == 0 && + strstr (fields[i].value, "--expected error from testcase--")) + return G_LOG_WRITER_HANDLED; + } - return TRUE; + return G_LOG_WRITER_UNHANDLED; } static void @@ -116,8 +110,7 @@ test_fast (void) DConfClient *client; gint i; - g_log_set_default_handler (log_handler, NULL); - g_test_log_set_fatal_handler (fatal_log_handler, NULL); + g_log_set_writer_func (log_writer_cb, NULL, NULL); client = dconf_client_new (); g_signal_connect (client, "changed", G_CALLBACK (changed), NULL); |