summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2016-08-02 23:23:43 -0400
committerMatthias Clasen <mclasen@redhat.com>2016-08-02 23:23:43 -0400
commit5ab2b8f562095a3f4d44b8e5c86916e419f527aa (patch)
treeec59b09fea3a25cdfbbb907fe8bdcc9afae7e448 /testsuite
parentd9c07c0a6afc5fb5eae1ae8148f520b59b53937c (diff)
downloadgtk+-5ab2b8f562095a3f4d44b8e5c86916e419f527aa.tar.gz
Make icontheme test work with structured logging
Since we've opted in to G_LOG_USE_STRUCTURED, this test now needs to do its thing using a log writer function.
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/gtk/icontheme.c35
1 files changed, 26 insertions, 9 deletions
diff --git a/testsuite/gtk/icontheme.c b/testsuite/gtk/icontheme.c
index f61b5f1aad..a70f75b240 100644
--- a/testsuite/gtk/icontheme.c
+++ b/testsuite/gtk/icontheme.c
@@ -122,18 +122,35 @@ assert_icon_lookup_fails (const char *icon_name,
static GList *lookups = NULL;
-static void
-log_func (const gchar *log_domain,
- GLogLevelFlags log_level,
- const gchar *string,
- gpointer user_data)
+static GLogWriterOutput
+log_writer (GLogLevelFlags log_level,
+ const GLogField *fields,
+ gsize n_fields,
+ gpointer user_data)
{
- if (g_str_has_prefix (string, "\tlookup name: "))
+ const char *domain = NULL;
+ const char *msg = NULL;
+ int i;
+
+ for (i = 0; i < n_fields; i++)
+ {
+ if (strcmp (fields[i].key, "GLIB_DOMAIN") == 0)
+ domain = fields[i].value;
+ if (strcmp (fields[i].key, "MESSAGE") == 0)
+ msg = fields[i].value;
+ }
+
+ if (log_level != G_LOG_LEVEL_MESSAGE || g_strcmp0 (domain, "Gtk") != 0)
+ return g_log_writer_default (log_level, fields, n_fields, user_data);
+
+ if (g_str_has_prefix (msg, "\tlookup name: "))
{
gchar *s;
- s = g_strchomp (g_strdup (string + strlen ("\tlookup name: ")));
+ s = g_strchomp (g_strdup (msg + strlen ("\tlookup name: ")));
lookups = g_list_append (lookups, s);
}
+
+ return G_LOG_WRITER_HANDLED;
}
static void
@@ -151,7 +168,7 @@ assert_lookup_order (const char *icon_name,
debug_flags = gtk_get_debug_flags ();
gtk_set_debug_flags (debug_flags | GTK_DEBUG_ICONTHEME);
- g_log_set_handler ("Gtk", G_LOG_LEVEL_MESSAGE, log_func, NULL);
+ g_log_set_writer_func (log_writer, NULL, NULL);
g_assert (lookups == NULL);
@@ -175,7 +192,7 @@ assert_lookup_order (const char *icon_name,
g_list_free_full (lookups, g_free);
lookups = NULL;
- g_log_set_handler ("Gtk", G_LOG_LEVEL_MESSAGE, g_log_default_handler, NULL);
+ g_log_set_writer_func (g_log_writer_default, NULL, NULL);
gtk_set_debug_flags (debug_flags);
}