diff options
| author | David Härdeman <david@hardeman.nu> | 2020-06-16 13:15:33 +0200 | 
|---|---|---|
| committer | David Härdeman <david@hardeman.nu> | 2020-06-16 13:15:33 +0200 | 
| commit | 9eeffbeab84e71bd0a4cc0855cb1f72ad1849ba6 (patch) | |
| tree | 40e3ee77ce70f8ed2137c3f92ec72e980630e45b /main.h | |
| parent | cab7429706aa6fce9d217ba6c5e3b6e5557914d5 (diff) | |
Some more debug cleanups
Diffstat (limited to 'main.h')
| -rw-r--r-- | main.h | 31 | 
1 files changed, 20 insertions, 11 deletions
@@ -27,17 +27,26 @@ debug_enabled(enum debug_category category)  	return !!(category & debug_mask);  } -void do_debug(enum debug_category category, const char *fmt, ...); - -#define __debug(c, ...) do { if (debug_enabled((c))) do_debug((c), __VA_ARGS__); } while (0) -#define debug(c, fmt, ...) __debug(c, "%s:" fmt, __func__, __VA_ARGS__) -#define verbose(...) __debug(DBG_VERBOSE, __VA_ARGS__) -#define info(...) __debug(DBG_ERROR, __VA_ARGS__) -#define error(...) __debug(DBG_ERROR, __VA_ARGS__) - -void die(const char *fmt, ...); - -#define perrordie(msg) die("%s: %m\n", msg) +void __debug(enum debug_category category, const char *fmt, ...) __attribute__((format(printf, 2, 3))); + +#define __ifdebug(c, fmt, ...) 						\ +	do {								\ +		if (debug_enabled((c)))					\ +			__debug((c), fmt __VA_OPT__(,) __VA_ARGS__);	\ +	} while (0) + +#define debug(c, fmt, ...)	__ifdebug((c), "%s:%i: " fmt, __func__, \ +					  __LINE__, __VA_ARGS__) +#define verbose(fmt, ...)	__ifdebug(DBG_VERBOSE, fmt, __VA_ARGS__) +#define info(fmt, ...)		__ifdebug(DBG_ERROR, fmt,  __VA_ARGS__) +#define error(fmt, ...)		__ifdebug(DBG_ERROR, fmt,  __VA_ARGS__) + +void __die(const char *fmt, ...) __attribute__((format(printf, 1, 2))); + +#define die(fmt, ...)		__die("%s:%i: " fmt "\n", __func__, \ +				      __LINE__  __VA_OPT__(,) __VA_ARGS__) +#define perrordie(fmt, ...)	__die("%s:%i: " fmt ": %m\n", __func__, \ +				      __LINE__  __VA_OPT__(,) __VA_ARGS__)  struct uring_task;  | 
