Merge pull request #847 from fwSmit/log-testing

logging: Set loglevel to error when testing.
This commit is contained in:
Nikos Tsipinakis 2021-05-26 20:06:13 +02:00 committed by GitHub
commit 1040febfb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -74,19 +74,21 @@ static void dunst_log_handler(
gpointer testing) gpointer testing)
{ {
if (testing) if (testing)
return; log_level = G_LOG_LEVEL_ERROR;
GLogLevelFlags message_level_masked = message_level & G_LOG_LEVEL_MASK;
/* if you want to have a debug build, you want to log anything, /* if you want to have a debug build, you want to log anything,
* unconditionally, without specifying debug log level again */ * unconditionally, without specifying debug log level again */
#ifndef DEBUG_BUILD #ifndef DEBUG_BUILD
if (log_level < message_level) if (log_level < message_level_masked)
return; return;
#endif #endif
const char *log_level_str = const char *log_level_str =
log_level_to_string(message_level & G_LOG_LEVEL_MASK); log_level_to_string(message_level_masked);
/* Use stderr for warnings and higher */ /* Use stderr for warnings and higher */
if (message_level <= G_LOG_LEVEL_WARNING) if (message_level_masked <= G_LOG_LEVEL_WARNING)
g_printerr("%s: %s\n", log_level_str, message); g_printerr("%s: %s\n", log_level_str, message);
else else
g_print("%s: %s\n", log_level_str, message); g_print("%s: %s\n", log_level_str, message);