log: remove deprecated SPICE_ABORT_LEVEL support

This feature was marked obsolete by efd1d3cb4d more than
three years ago.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
This commit is contained in:
Frediano Ziglio 2017-06-13 15:31:34 +01:00
parent e307130c18
commit ea20b8c013
2 changed files with 2 additions and 68 deletions

View File

@ -33,11 +33,6 @@
#include "backtrace.h"
static int glib_debug_level = INT_MAX;
static int abort_mask = 0;
#ifndef SPICE_ABORT_MASK_DEFAULT
#define SPICE_ABORT_MASK_DEFAULT (G_LOG_LEVEL_CRITICAL|G_LOG_LEVEL_ERROR)
#endif
#define G_LOG_DOMAIN "Spice"
@ -101,29 +96,6 @@ static void spice_log_set_debug_level(void)
}
}
static void spice_log_set_abort_level(void)
{
if (abort_mask == 0) {
const char *abort_str = g_getenv("SPICE_ABORT_LEVEL");
if (abort_str != NULL) {
GLogLevelFlags glib_abort_level;
/* FIXME: To be removed after enough deprecation time */
g_warning("Setting SPICE_ABORT_LEVEL is deprecated, use G_DEBUG instead");
glib_abort_level = spice_log_level_to_glib(atoi(abort_str));
unsigned int fatal_mask = G_LOG_FATAL_MASK;
while (glib_abort_level >= G_LOG_LEVEL_ERROR) {
fatal_mask |= glib_abort_level;
glib_abort_level >>= 1;
}
abort_mask = fatal_mask;
g_log_set_fatal_mask(G_LOG_DOMAIN, fatal_mask);
} else {
abort_mask = SPICE_ABORT_MASK_DEFAULT;
}
}
}
static void spice_logger(const gchar *log_domain,
GLogLevelFlags log_level,
const gchar *message,
@ -139,7 +111,6 @@ SPICE_CONSTRUCTOR_FUNC(spice_log_init)
{
spice_log_set_debug_level();
spice_log_set_abort_level();
if (glib_debug_level != INT_MAX) {
/* If SPICE_DEBUG_LEVEL is set, we need a custom handler, which is
* going to break use of g_log_set_default_handler() by apps
@ -182,7 +153,7 @@ static void spice_logv(const char *log_domain,
g_log(log_domain, log_level, "%s", log_msg->str);
g_string_free(log_msg, TRUE);
if ((abort_mask & log_level) != 0) {
if ((log_level & G_LOG_LEVEL_CRITICAL) != 0) {
spice_backtrace();
abort();
}

View File

@ -44,37 +44,6 @@ LOG_OTHER_HELPER(warning, WARNING)
LOG_OTHER_HELPER(critical, CRITICAL)
#if GLIB_CHECK_VERSION(2,38,0)
/* Checks that spice_warning() aborts after changing SPICE_ABORT_LEVEL */
static void test_spice_abort_level(void)
{
if (g_test_subprocess()) {
spice_warning("spice_warning");
return;
}
/* 2 = SPICE_LOG_LEVEL_WARNING */
g_setenv("SPICE_ABORT_LEVEL", "2", TRUE);
g_test_trap_subprocess(NULL, 0, 0);
g_unsetenv("SPICE_ABORT_LEVEL");
g_test_trap_assert_failed();
g_test_trap_assert_stderr("*SPICE_ABORT_LEVEL*deprecated*");
g_test_trap_assert_stderr("*spice_warning*");
}
/* Checks that g_warning() aborts after changing SPICE_ABORT_LEVEL */
static void test_spice_abort_level_g_warning(void)
{
if (g_test_subprocess()) {
g_warning("g_warning");
return;
}
g_setenv("SPICE_ABORT_LEVEL", "2", TRUE);
g_test_trap_subprocess(NULL, 0, 0);
g_unsetenv("SPICE_ABORT_LEVEL");
g_test_trap_assert_failed();
g_test_trap_assert_stderr("*SPICE_ABORT_LEVEL*deprecated*");
g_test_trap_assert_stderr("*g_warning*");
}
/* Checks that spice_warning() aborts after setting G_DEBUG=fatal-warnings */
static void test_spice_fatal_warning(void)
{
@ -283,7 +252,6 @@ static void test_spice_debug_level_warning(void)
spice_info("spice_info");
spice_debug("spice_debug");
spice_warning("spice_warning");
spice_critical("spice_critical");
g_debug("g_debug");
g_info("g_info");
g_message("g_message");
@ -298,15 +266,12 @@ static void test_spice_debug_level_warning(void)
return;
}
g_setenv("SPICE_ABORT_LEVEL", "0", TRUE);
g_setenv("SPICE_DEBUG_LEVEL", "1", TRUE);
g_test_trap_subprocess(NULL, 0, 0);
g_unsetenv("SPICE_ABORT_LEVEL");
g_unsetenv("SPICE_DEBUG_LEVEL");
g_test_trap_assert_passed();
g_test_trap_assert_stderr("*SPICE_DEBUG_LEVEL*deprecated*");
g_test_trap_assert_stderr("*SPICE_ABORT_LEVEL*deprecated*");
g_test_trap_assert_stderr("*spice_critical\n*g_critical\n*other_message\n*other_warning\n*other_critical\n");
g_test_trap_assert_stderr("*g_critical\n*other_message\n*other_warning\n*other_critical\n");
g_test_trap_assert_stdout_unmatched("*spice_info*");
g_test_trap_assert_stdout_unmatched("*spice_debug*");
g_test_trap_assert_stderr_unmatched("*spice_warning*");
@ -393,8 +358,6 @@ int main(int argc, char **argv)
g_log_set_always_fatal(fatal_mask & G_LOG_LEVEL_MASK);
#if GLIB_CHECK_VERSION(2,38,0)
g_test_add_func("/spice-common/spice-abort-level", test_spice_abort_level);
g_test_add_func("/spice-common/spice-abort-level-gwarning", test_spice_abort_level_g_warning);
g_test_add_func("/spice-common/spice-debug-level", test_spice_debug_level);
g_test_add_func("/spice-common/spice-debug-level-warning", test_spice_debug_level_warning);
g_test_add_func("/spice-common/spice-g-messages-debug", test_spice_g_messages_debug);