Testing: Add a basic print-to-stdout log handler as a test debugging aid.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22112 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
John Ralls 2012-03-24 22:19:58 +00:00
parent e6c0795652
commit b5c62a1385
2 changed files with 20 additions and 0 deletions

View File

@ -450,6 +450,17 @@ test_checked_handler (const char *log_domain, GLogLevelFlags log_level,
}
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 )
{

View File

@ -112,6 +112,15 @@ typedef struct
*/
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.