r22112 - gnucash/trunk/src/test-core - Testing: Add a basic print-to-stdout log handler as a test debugging aid.

John Ralls jralls at code.gnucash.org
Sat Mar 24 18:19:58 EDT 2012


Author: jralls
Date: 2012-03-24 18:19:58 -0400 (Sat, 24 Mar 2012)
New Revision: 22112
Trac: http://svn.gnucash.org/trac/changeset/22112

Modified:
   gnucash/trunk/src/test-core/test-stuff.c
   gnucash/trunk/src/test-core/test-stuff.h
Log:
Testing: Add a basic print-to-stdout log handler as a test debugging aid.

Modified: gnucash/trunk/src/test-core/test-stuff.c
===================================================================
--- gnucash/trunk/src/test-core/test-stuff.c	2012-03-23 20:52:13 UTC (rev 22111)
+++ gnucash/trunk/src/test-core/test-stuff.c	2012-03-24 22:19:58 UTC (rev 22112)
@@ -450,6 +450,17 @@
 
 }
 
+gboolean
+test_log_handler (const char *log_domain, GLogLevelFlags log_level,
+                      const gchar *msg, gpointer user_data )
+{
+    gchar *level = test_log_level (log_level);
+    g_printf ( "<%s> (%s) %s\n", level, log_domain, msg);
+    g_free (level);
+    g_assert (log_level ^ G_LOG_FLAG_FATAL);
+    return FALSE;
+}
+
 void
 test_set_called( const gboolean val )
 {

Modified: gnucash/trunk/src/test-core/test-stuff.h
===================================================================
--- gnucash/trunk/src/test-core/test-stuff.h	2012-03-23 20:52:13 UTC (rev 22111)
+++ gnucash/trunk/src/test-core/test-stuff.h	2012-03-24 22:19:58 UTC (rev 22112)
@@ -112,7 +112,16 @@
  */
 gboolean test_checked_handler (const char *log_domain, GLogLevelFlags log_level,
                                const gchar *msg, gpointer user_data);
+
 /**
+ * Just print the log message. Since GLib has a habit of eating its
+ * log messages, it's sometimes useful to call
+ * g_test_log_set_fatal_handler() with this to make sure that
+ * g_return_if_fail() error messages make it to the surface.
+ */
+gboolean test_log_handler (const char *log_domain, GLogLevelFlags log_level,
+			   const gchar *msg, gpointer user_data);
+/**
  * Just returns FALSE or suppresses the message regardless of what the
  * error is. Use this only as a last resort.
  */



More information about the gnucash-changes mailing list