diff options
Diffstat (limited to 'main.h')
-rw-r--r-- | main.h | 24 |
1 files changed, 12 insertions, 12 deletions
@@ -12,7 +12,7 @@ extern bool exiting; extern unsigned debug_mask; -enum debug_category { +enum debug_lvl { DBG_ERROR = (0x1 << 1), DBG_INFO = (0x1 << 2), DBG_VERBOSE = (0x1 << 3), @@ -31,31 +31,31 @@ enum debug_category { }; static inline bool -debug_enabled(enum debug_category category) +debug_enabled(enum debug_lvl lvl) { - return !!(category & debug_mask); + return !!(lvl & debug_mask); } -void __debug(enum debug_category category, const char *fmt, ...) __attribute__((format(printf, 2, 3))); +void __debug(enum debug_lvl lvl, const char *fmt, ...) __attribute__((format(printf, 2, 3))); -#define __ifdebug(c, fmt, ...) \ - do { \ - if (debug_enabled((c))) \ - __debug((c), fmt __VA_OPT__(,) __VA_ARGS__); \ +#define __ifdebug(lvl, fmt, ...) \ + do { \ + if (debug_enabled((lvl))) \ + __debug((lvl), fmt __VA_OPT__(,) __VA_ARGS__); \ } while (0) -#define debug(c, fmt, ...) __ifdebug((c), "%s:%i: " fmt, __func__, \ +#define debug(lvl, fmt, ...) __ifdebug((lvl), "%s:%i: " fmt, __func__, \ __LINE__ __VA_OPT__(,) __VA_ARGS__) #define verbose(fmt, ...) __ifdebug(DBG_VERBOSE, fmt, __VA_ARGS__) -#define info(fmt, ...) __ifdebug(DBG_ERROR, fmt, __VA_ARGS__) +#define info(fmt, ...) __ifdebug(DBG_INFO, fmt, __VA_ARGS__) #define error(fmt, ...) __ifdebug(DBG_ERROR, "%s: " fmt, \ __func__ __VA_OPT__(,) __VA_ARGS__) void __die(const char *fmt, ...) __attribute__((format(printf, 1, 2))); -#define die(fmt, ...) __die("%s:%i: " fmt "\n", __func__, \ +#define die(fmt, ...) __die("%s:%i: " fmt "\n", __func__, \ __LINE__ __VA_OPT__(,) __VA_ARGS__) -#define perrordie(fmt, ...) __die("%s:%i: " fmt ": %m\n", __func__, \ +#define perrordie(fmt, ...) __die("%s:%i: " fmt ": %m\n", __func__, \ __LINE__ __VA_OPT__(,) __VA_ARGS__) struct uring_task; |