From 7a631d32c72a0290792d8cd20f2b5d6e3f0af9e5 Mon Sep 17 00:00:00 2001 From: David Härdeman Date: Wed, 17 Jun 2020 15:19:57 +0200 Subject: Add some more basic options, and improve logging a bit more --- main.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'main.h') diff --git a/main.h b/main.h index 282d827..4de0884 100644 --- a/main.h +++ b/main.h @@ -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; -- cgit v1.2.3