Add a LOG() macro which handles dynamic severity levels
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 6 Aug 2015 18:57:17 +0000 (14:57 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 6 Aug 2015 18:57:57 +0000 (14:57 -0400)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/common/error.h

index 1ee6e675a5b752eb600c0e2f4d19dc2891fcd6e7..00519d840c65f20475b61c8b4ab43506728ad754 100644 (file)
@@ -106,6 +106,34 @@ extern int lttng_opt_mi;
 #define DBG(fmt, args...) _ERRMSG("DEBUG1", PRINT_DBG, fmt, ## args)
 #define DBG2(fmt, args...) _ERRMSG("DEBUG2", PRINT_DBG2, fmt, ## args)
 #define DBG3(fmt, args...) _ERRMSG("DEBUG3", PRINT_DBG3, fmt, ## args)
+#define LOG(type, fmt, args...)                        \
+       do {                                    \
+               switch (type) {                 \
+               case PRINT_ERR:                 \
+                       ERR(fmt, ## args);      \
+                       break;                  \
+               case PRINT_WARN:                \
+                       WARN(fmt, ## args);     \
+                       break;                  \
+               case PRINT_BUG:                 \
+                       BUG(fmt, ## args);      \
+                       break;                  \
+               case PRINT_MSG:                 \
+                       MSG(fmt, ## args);      \
+                       break;                  \
+               case PRINT_DBG:                 \
+                       DBG(fmt, ## args);      \
+                       break;                  \
+               case PRINT_DBG2:                \
+                       DBG2(fmt, ## args);     \
+                       break;                  \
+               case PRINT_DBG3:                \
+                       DBG3(fmt, ## args);     \
+                       break;                  \
+               default:                        \
+                       assert(0);              \
+               }                               \
+       } while(0);
 
 #define _PERROR(fmt, args...) _ERRMSG("PERROR", PRINT_ERR, fmt, ## args)
 
This page took 0.026041 seconds and 4 git commands to generate.