[Spice-devel] [PATCH spice-common 1/2] log: remove deprecated SPICE_ABORT_LEVEL support

Frediano Ziglio fziglio at redhat.com
Tue Jun 13 14:47:53 UTC 2017


This feature was marked obsolete by efd1d3cb4d8eee more than
an year ago.

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 common/log.c         | 27 ++-------------------------
 tests/test-logging.c | 39 +--------------------------------------
 2 files changed, 3 insertions(+), 63 deletions(-)

diff --git a/common/log.c b/common/log.c
index 92f5bc0..ee13777 100644
--- a/common/log.c
+++ b/common/log.c
@@ -31,7 +31,6 @@
 #include "backtrace.h"
 
 static int glib_debug_level = INT_MAX;
-static int abort_mask = 0;
 
 #ifndef SPICE_ABORT_MASK_DEFAULT
 #ifdef SPICE_DISABLE_ABORT
@@ -41,6 +40,8 @@ static int abort_mask = 0;
 #endif
 #endif
 
+static const int abort_mask = SPICE_ABORT_MASK_DEFAULT;
+
 typedef enum {
     SPICE_LOG_LEVEL_ERROR,
     SPICE_LOG_LEVEL_CRITICAL,
@@ -101,29 +102,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(SPICE_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 +117,6 @@ SPICE_CONSTRUCTOR_FUNC(spice_log_init)
 {
 
     spice_log_set_debug_level();
-    spice_log_set_abort_level();
     g_log_set_handler(SPICE_LOG_DOMAIN,
                       G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION,
                       spice_logger, NULL);
diff --git a/tests/test-logging.c b/tests/test-logging.c
index f1ad1b6..c871648 100644
--- a/tests/test-logging.c
+++ b/tests/test-logging.c
@@ -45,37 +45,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)
 {
@@ -287,7 +256,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");
@@ -302,15 +270,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");
 }
 
 /* Checks that setting G_MESSAGES_DEBUG to 'Spice' impacts spice_debug() and
@@ -387,8 +352,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);
-- 
2.9.4



More information about the Spice-devel mailing list