From 7d9ad8800792b112461e469d774a0abb5ff06043 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Thu, 6 Aug 2015 14:57:17 -0400 Subject: [PATCH] Add a LOG() macro which handles dynamic severity levels MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- src/common/error.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/common/error.h b/src/common/error.h index 1ee6e675a..00519d840 100644 --- a/src/common/error.h +++ b/src/common/error.h @@ -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) -- 2.34.1