diff options
author | David Härdeman <david@hardeman.nu> | 2020-06-17 15:19:57 +0200 |
---|---|---|
committer | David Härdeman <david@hardeman.nu> | 2020-06-17 15:19:57 +0200 |
commit | 7a631d32c72a0290792d8cd20f2b5d6e3f0af9e5 (patch) | |
tree | 18083e3fc39a9a937175b4e19dacf9a12dffdee9 /main.h | |
parent | 688a44577ac447362b8a7570764edc34b48b30a9 (diff) |
Add some more basic options, and improve logging a bit more
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; |