summaryrefslogtreecommitdiff
path: root/toxcore/logger.h
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2018-10-08 23:53:04 +0000
committeriphydf <iphydf@users.noreply.github.com>2018-10-19 18:08:46 +0000
commitaa5c7828802b3fcaedfd8d6fe9a08ca714b9aa2b (patch)
treeccdf7bb4d10995d03e4b385589cdbea3d4eb97b6 /toxcore/logger.h
parent1eaa55d2d4f62e73204d8f68ce05fdebb1ab827c (diff)
Add `LOGGER_ASSERT` for checking fatal error conditions.
These are not compiled out under `NDEBUG` and should be provably correct.
Diffstat (limited to 'toxcore/logger.h')
-rw-r--r--toxcore/logger.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/toxcore/logger.h b/toxcore/logger.h
index 2cae7a0e..3abed896 100644
--- a/toxcore/logger.h
+++ b/toxcore/logger.h
@@ -91,4 +91,18 @@ void logger_write(
91#define LOGGER_WARNING(log, ...) LOGGER_WRITE(log, LOGGER_LEVEL_WARNING, __VA_ARGS__) 91#define LOGGER_WARNING(log, ...) LOGGER_WRITE(log, LOGGER_LEVEL_WARNING, __VA_ARGS__)
92#define LOGGER_ERROR(log, ...) LOGGER_WRITE(log, LOGGER_LEVEL_ERROR , __VA_ARGS__) 92#define LOGGER_ERROR(log, ...) LOGGER_WRITE(log, LOGGER_LEVEL_ERROR , __VA_ARGS__)
93 93
94#define LOGGER_FATAL(log, ...) \
95 do { \
96 LOGGER_ERROR(log, __VA_ARGS__); \
97 abort(); \
98 } while(0)
99
100#define LOGGER_ASSERT(log, cond, ...) \
101 do { \
102 if (!(cond)) { \
103 LOGGER_ERROR(log, "Assertion failed"); \
104 LOGGER_FATAL(log, __VA_ARGS__); \
105 } \
106 } while(0)
107
94#endif // C_TOXCORE_TOXCORE_LOGGER_H 108#endif // C_TOXCORE_TOXCORE_LOGGER_H