Suppress Telepathy logger warning for tests.
authorTravis Reitter <travis.reitter@collabora.co.uk>
Mon, 17 Jan 2011 19:37:55 +0000 (11:37 -0800)
committerTravis Reitter <travis.reitter@collabora.co.uk>
Mon, 17 Jan 2011 23:00:44 +0000 (15:00 -0800)
Fixes bgo#639742 - Logger service unavailable in make check

NEWS
tests/lib/telepathy/contactlist/backend.c

diff --git a/NEWS b/NEWS
index afa8d23..0205d4a 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -14,6 +14,7 @@ Bugs fixed:
 * Bug 639195 — Print stack traces for failed tests to improve remote
   debugging
 * Bug 639113 — Add static aggregation tests
+* Bug 639742 — Logger service unavailable in make check
 
 Overview of changes from libfolks 0.3.2 to libfolks 0.3.3
 =========================================================
index 9b5168f..9710c0b 100644 (file)
@@ -132,22 +132,38 @@ tp_test_backend_new (void)
 }
 
 static gboolean
-_log_fatal_handler (const char *domain,
+_log_should_suppress (const char *domain,
    GLogLevelFlags flags,
-   const char *message,
-   gpointer user_data)
+   const char *message)
 {
-  gboolean fatal;
-
   /* Ignore the error caused by not running the logger */
-  fatal = !g_str_has_suffix (message,
+  return g_str_has_suffix (message,
       "The name org.freedesktop.Telepathy.Logger was not provided by any "
       ".service files");
+}
+
+static void
+_log_default_handler (const char *domain,
+   GLogLevelFlags flags,
+   const char *message,
+   gpointer user_data)
+{
+  if (!_log_should_suppress (domain, flags, message))
+    g_log_default_handler (domain, flags, message, user_data);
+}
+
+static gboolean
+_log_fatal_handler (const char *domain,
+   GLogLevelFlags flags,
+   const char *message,
+   gpointer user_data)
+{
+  gboolean suppress = _log_should_suppress (domain, flags, message);
 
-  if (fatal)
+  if (!suppress)
     g_on_error_stack_trace ("libtool --mode=exec gdb");
 
-  return fatal;
+  return !suppress;
 }
 
 void
@@ -157,7 +173,7 @@ tp_test_backend_set_up (TpTestBackend *self)
   GError *error = NULL;
 
   /* Override the handler set in the general Folks.TestCase class */
-  g_log_set_default_handler (g_log_default_handler, NULL);
+  g_log_set_default_handler (_log_default_handler, NULL);
   g_test_log_set_fatal_handler (_log_fatal_handler, NULL);
 
   priv->daemon = tp_dbus_daemon_dup (&error);