From: Jérémie Galarneau Date: Thu, 6 Aug 2015 18:57:17 +0000 (-0400) Subject: Add a LOG() macro which handles dynamic severity levels X-Git-Tag: v2.7.0~3 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=9047ce05ecadee2929751aa4605f62b07fcc130b;p=lttng-tools.git Add a LOG() macro which handles dynamic severity levels Signed-off-by: Jérémie Galarneau --- 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)