[logging] Wrapping logging statements in a do while (0) so the compiler always at least sees debug code
This commit is contained in:
@@ -20,9 +20,10 @@
|
|||||||
#define NO_DEBUG 1
|
#define NO_DEBUG 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef NO_DEBUG
|
#ifdef NO_DEBUG
|
||||||
/* compile with all debug messages removed */
|
/* compile with all debug messages removed */
|
||||||
#define log_debug(M, ...)
|
#define log_debug(M, ...) do { if (0) fprintf(stderr, "\33[34mDEBUG\33[39m " M " \33[90m at %s (%s:%d) \33[39m\n", ##__VA_ARGS__, __func__, __FILE__, __LINE__); } while (0)
|
||||||
#else
|
#else
|
||||||
#ifdef LOG_NO_COLORS
|
#ifdef LOG_NO_COLORS
|
||||||
#define log_debug(M, ...) fprintf(stderr, "DEBUG " M " at %s (%s:%d) \n", ##__VA_ARGS__, __func__, __FILE__, __LINE__)
|
#define log_debug(M, ...) fprintf(stderr, "DEBUG " M " at %s (%s:%d) \n", ##__VA_ARGS__, __func__, __FILE__, __LINE__)
|
||||||
@@ -46,17 +47,17 @@
|
|||||||
|
|
||||||
#if LOG_LEVEL > LOG_LEVEL_INFO
|
#if LOG_LEVEL > LOG_LEVEL_INFO
|
||||||
#undef log_info
|
#undef log_info
|
||||||
#define log_info(M, ...)
|
#define log_info(M, ...) do { if (0) fprintf(stderr, "\33[31mERR\33[39m " M " \33[90m at %s (%s:%d) \33[94merrno: %s\33[39m\n", ##__VA_ARGS__, __func__, __FILE__, __LINE__, clean_errno()); } while(0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if LOG_LEVEL > LOG_LEVEL_WARN
|
#if LOG_LEVEL > LOG_LEVEL_WARN
|
||||||
#undef log_warn
|
#undef log_warn
|
||||||
#define log_warn(M, ...)
|
#define log_warn(M, ...) do { if (0) fprintf(stderr, "\33[91mWARN\33[39m " M " \33[90m at %s (%s:%d) \33[94merrno: %s\33[39m\n", ##__VA_ARGS__, __func__, __FILE__, __LINE__, clean_errno()); } while (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if LOG_LEVEL > LOG_LEVEL_ERROR
|
#if LOG_LEVEL > LOG_LEVEL_ERROR
|
||||||
#undef log_error
|
#undef log_error
|
||||||
#define log_error(M, ...)
|
#define log_error(M, ...) do { if (0) fprintf(stderr, "\33[32mINFO\33[39m " M " \33[90m at %s (%s:%d) \33[39m\n", ##__VA_ARGS__, __func__, __FILENAME__, __LINE__); } while (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user