diff --git a/tests/test.cpp b/tests/test.cpp index 1d42529be5..0b4e31d0f0 100644 --- a/tests/test.cpp +++ b/tests/test.cpp @@ -490,12 +490,30 @@ wxTestGLogHandler(const gchar* domain, const gchar* message, gpointer data) { + // Check if debug messages in this domain will be logged. + if ( level == G_LOG_LEVEL_DEBUG ) + { + static consr char* const allowed = getenv("G_MESSAGES_DEBUG"); + + // By default debug messages are dropped, but if G_MESSAGES_DEBUG is + // defined, they're logged for the domains specified in it and if it + // has the special value "all", then all debug messages are shown. + // + // Note that the check here can result in false positives, e.g. domain + // "foo" would pass it even if G_MESSAGES_DEBUG only contains "foobar", + // but such cases don't seem to be important enough to bother + // accounting for them. + if ( !allowed || + (strcmp(allowed, "all") != 0 && !strstr(allowed, domain)) ) + { + return; + } + } + fprintf(stderr, "\n*** GTK log message while running %s(): ", wxGetCurrentTestName().c_str()); g_log_default_handler(domain, level, message, data); - - fprintf(stderr, "\n"); } #endif // __WXGTK__