[Spice-devel] [spice-common v3 02/19] log: include message log level for parity with glib

Victor Toso victortoso at redhat.com
Sat Mar 12 14:32:03 UTC 2016


---
 common/log.c | 8 +++++---
 common/log.h | 7 +++++++
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/common/log.c b/common/log.c
index 8d47cb6..9c2f2b2 100644
--- a/common/log.c
+++ b/common/log.c
@@ -43,15 +43,17 @@ static int abort_level = -1;
 
 static GLogLevelFlags spice_log_level_to_glib(SpiceLogLevel level)
 {
-    static const GLogLevelFlags glib_levels[] = {
+    static const GLogLevelFlags glib_levels[SPICE_LOG_NUM_LEVELS] = {
+        [ SPICE_LOG_LEVEL_NONE ] = 0,
         [ SPICE_LOG_LEVEL_ERROR ] = G_LOG_LEVEL_ERROR,
         [ SPICE_LOG_LEVEL_CRITICAL ] = G_LOG_LEVEL_CRITICAL,
         [ SPICE_LOG_LEVEL_WARNING ] = G_LOG_LEVEL_WARNING,
+        [ SPICE_LOG_LEVEL_MESSAGE ] = G_LOG_LEVEL_MESSAGE,
         [ SPICE_LOG_LEVEL_INFO ] = G_LOG_LEVEL_INFO,
         [ SPICE_LOG_LEVEL_DEBUG ] = G_LOG_LEVEL_DEBUG,
     };
-    g_return_val_if_fail (level >= 0, G_LOG_LEVEL_ERROR);
-    g_return_val_if_fail (level < G_N_ELEMENTS(glib_levels), G_LOG_LEVEL_DEBUG);
+    g_return_val_if_fail (level >= SPICE_LOG_LEVEL_NONE, G_LOG_LEVEL_ERROR);
+    g_return_val_if_fail (level < SPICE_LOG_NUM_LEVELS, G_LOG_LEVEL_DEBUG);
 
     return glib_levels[level];
 }
diff --git a/common/log.h b/common/log.h
index 68f11ca..68f6a24 100644
--- a/common/log.h
+++ b/common/log.h
@@ -33,11 +33,15 @@ SPICE_BEGIN_DECLS
 #define SPICE_STRLOC  __FILE__ ":" G_STRINGIFY (__LINE__)
 
 typedef enum {
+    SPICE_LOG_LEVEL_NONE,
     SPICE_LOG_LEVEL_ERROR,
     SPICE_LOG_LEVEL_CRITICAL,
     SPICE_LOG_LEVEL_WARNING,
+    SPICE_LOG_LEVEL_MESSAGE,
     SPICE_LOG_LEVEL_INFO,
     SPICE_LOG_LEVEL_DEBUG,
+
+    SPICE_LOG_NUM_LEVELS
 } SpiceLogLevel;
 
 void spice_log(const char *log_domain,
@@ -88,6 +92,9 @@ void spice_log(const char *log_domain,
 #define spice_warning(format, ...) \
     SPICE_LOG(SPICE_LOG_LEVEL_WARNING, format, ## __VA_ARGS__)
 
+#define spice_message(format, ...) \
+    SPICE_LOG(SPICE_LOG_LEVEL_MESSAGE, format, ## __VA_ARGS__)
+
 #define spice_critical(format, ...) \
     SPICE_LOG(SPICE_LOG_LEVEL_CRITICAL, format, ## __VA_ARGS__)
 
-- 
2.5.0



More information about the Spice-devel mailing list