Skip to content

Commit

Permalink
Testing: Add a basic print-to-stdout log handler as a test debugging …
Browse files Browse the repository at this point in the history
…aid.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22112 57a11ea4-9604-0410-9ed3-97b8803252fd
  • Loading branch information
jralls committed Mar 24, 2012
1 parent e6c0795 commit b5c62a1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/test-core/test-stuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand Down
9 changes: 9 additions & 0 deletions src/test-core/test-stuff.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit b5c62a1

Please sign in to comment.