1 #ifndef LIBWESTON_TRACE 2 #define LIBWESTON_TRACE 3 4 #include <stdio.h> 5 6 #define _LOG(func, line, color, fmt, ...) \ 7 log_printf(LABEL, func, line, "\033[" #color "m" fmt, ##__VA_ARGS__) 8 9 #define LOG_ENTER() log_enter(LABEL, __func__, __LINE__) 10 #define LOG_EXIT() log_exit(LABEL, __func__, __LINE__) 11 #define LOG_ENTERS(str) log_enters(LABEL, __func__, __LINE__, str) 12 #define LOG_EXITS(str) log_exits(LABEL, __func__, __LINE__, str) 13 #define LOG_INFO(fmt, ...) _LOG(__func__, __LINE__, 36, fmt, ##__VA_ARGS__) 14 #define LOG_CORE(fmt, ...) _LOG(__func__, __LINE__, 35, "core: " fmt, ##__VA_ARGS__) 15 #define LOG_ERROR(fmt, ...) _LOG(__func__, __LINE__, 31, fmt, ##__VA_ARGS__) 16 #define LOG_PASS() _LOG(__func__, __LINE__, 32, "pass") 17 #define DEFINE_LOG_LABEL(str) static const char *LABEL = str; 18 19 #define LOG_REGION(note, region) \ 20 LOG_INFO(#note " " #region " (%d, %d) (%d, %d)", \ 21 (region)->extents.x1, (region)->extents.y1, \ 22 (region)->extents.x2, (region)->extents.y2) 23 24 #ifdef __cplusplus 25 extern "C" { 26 #endif 27 28 void log_init(); 29 void log_printf(const char *label, const char *func, int line, const char *fmt, ...); 30 void log_enter(const char *label, const char *func, int line); 31 void log_exit(const char *label, const char *func, int line); 32 void log_enters(const char *label, const char *func, int line, const char *str); 33 void log_exits(const char *label, const char *func, int line, const char *str); 34 35 #ifdef __cplusplus 36 } 37 #endif 38 39 #endif // LIBWESTON_TRACE 40