| 1 |
#ifndef LOGGER_H |
| 2 |
#define LOGGER_H |
| 3 |
|
| 4 |
#include <sys/cdefs.h> |
| 5 |
// clang-format off |
| 6 |
__attribute__ ((noinline)) void debug_print (const char *caller_func, const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); |
| 7 |
__attribute__ ((noinline)) void info_print (const char *caller_func, const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); |
| 8 |
__attribute__ ((noinline)) void warn_print (const char *caller_func, const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); |
| 9 |
__attribute__ ((noinline)) __attribute__ ((noreturn)) void error_print (const char *caller_func, const char *fmt, ...) __attribute__ ((format (printf, 2, 3))); |
| 10 |
// clang-format on |
| 11 |
|
| 12 |
#ifdef DEBUG |
| 13 |
#define debug(fmt, ...) debug_print (__func__, fmt, __VA_ARGS__) |
| 14 |
#else |
| 15 |
#define debug(fmt, ...) ; |
| 16 |
#endif // !DEBUG |
| 17 |
|
| 18 |
#define info(fmt, ...) info_print (__func__, fmt, __VA_ARGS__) |
| 19 |
#define warn(fmt, ...) warn_print (__func__, fmt, __VA_ARGS__) |
| 20 |
#define error(fmt, ...) error_print (__func__, fmt, __VA_ARGS__) |
| 21 |
|
| 22 |
#endif |