Rev 18 | Details | Compare with Previous | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line | 
|---|---|---|---|
| 1 | pmbaty | 1 | #ifndef HARNESS_TRACE_H | 
        
| 2 | #define HARNESS_TRACE_H | 
        ||
| 3 | |||
| 20 | pmbaty | 4 | #include "brender/br_types.h" | 
        
| 1 | pmbaty | 5 | #include <stdlib.h> | 
        
| 6 | |||
| 7 | extern int harness_debug_level;  | 
        ||
| 8 | |||
| 20 | pmbaty | 9 | void debug_printf(const char* fmt, const char* fn, const char* fmt2, ...);  | 
        
| 1 | pmbaty | 10 | void debug_print_vector3(const char* fmt, const char* fn, char* msg, br_vector3* v);  | 
        
| 11 | void debug_print_matrix34(const char* fmt, const char* fn, char* name, br_matrix34* m);  | 
        ||
| 12 | void debug_print_matrix4(const char* fmt, const char* fn, char* name, br_matrix4* m);  | 
        ||
| 13 | |||
| 14 | #define BLUE | 
        ||
| 15 | |||
| 16 | #define LOG_TRACE(...)                                         \ | 
        ||
| 17 |     if (harness_debug_level >= 5) {                            \ | 
        ||
| 18 |         debug_printf("[TRACE] %s", __FUNCTION__, __VA_ARGS__); \ | 
        ||
| 19 |     } | 
        ||
| 20 | |||
| 21 | #define LOG_TRACE10(...)                                       \ | 
        ||
| 22 |     if (harness_debug_level >= 10) {                           \ | 
        ||
| 23 |         debug_printf("[TRACE] %s", __FUNCTION__, __VA_ARGS__); \ | 
        ||
| 24 |     } | 
        ||
| 25 | #define LOG_TRACE9(...)                                        \ | 
        ||
| 26 |     if (harness_debug_level >= 9) {                            \ | 
        ||
| 27 |         debug_printf("[TRACE] %s", __FUNCTION__, __VA_ARGS__); \ | 
        ||
| 28 |     } | 
        ||
| 29 | |||
| 30 | #define LOG_TRACE8(...)                                        \ | 
        ||
| 31 |     if (harness_debug_level >= 8) {                            \ | 
        ||
| 32 |         debug_printf("[TRACE] %s", __FUNCTION__, __VA_ARGS__); \ | 
        ||
| 33 |     } | 
        ||
| 34 | |||
| 35 | #define LOG_DEBUG(...) debug_printf("\033[0;34m[DEBUG] %s ", __FUNCTION__, __VA_ARGS__) | 
        ||
| 36 | #define LOG_VEC(msg, v) debug_print_vector3("\033[0;34m[DEBUG] %s ", __FUNCTION__, msg, v) | 
        ||
| 37 | #define LOG_MATRIX(msg, m) debug_print_matrix34("\033[0;34m[DEBUG] %s ", __FUNCTION__, msg, m) | 
        ||
| 38 | #define LOG_MATRIX4(msg, m) debug_print_matrix4("\033[0;34m[DEBUG] %s ", __FUNCTION__, msg, m) | 
        ||
| 39 | #define LOG_INFO(...) debug_printf("[INFO] %s ", __FUNCTION__, __VA_ARGS__) | 
        ||
| 40 | #define LOG_WARN(...) debug_printf("\033[0;33m[WARN] %s ", __FUNCTION__, __VA_ARGS__) | 
        ||
| 41 | #define LOG_PANIC(...)                                                    \ | 
        ||
| 42 |     do {                                                                  \ | 
        ||
| 20 | pmbaty | 43 |         debug_printf("\033[0;31m[PANIC] %s ", __FUNCTION__, __VA_ARGS__); \ | 
        
| 1 | pmbaty | 44 |         abort();                                                          \ | 
        
| 45 |     } while (0) | 
        ||
| 46 | |||
| 47 | #define LOG_WARN_ONCE(...)                                               \ | 
        ||
| 48 |     static int warn_printed = 0;                                         \ | 
        ||
| 49 |     if (!warn_printed) {                                                 \ | 
        ||
| 50 |         debug_printf("\033[0;33m[WARN] %s ", __FUNCTION__, __VA_ARGS__); \ | 
        ||
| 51 |         warn_printed = 1;                                                \ | 
        ||
| 52 |     } | 
        ||
| 53 | |||
| 54 | #define NOT_IMPLEMENTED() \ | 
        ||
| 55 |     LOG_PANIC("not implemented") | 
        ||
| 56 | |||
| 57 | #define TELL_ME_IF_WE_PASS_THIS_WAY() \ | 
        ||
| 58 |     LOG_PANIC("code path not expected") | 
        ||
| 59 | |||
| 60 | #define STUB() \ | 
        ||
| 61 |     debug_printf("\033[0;31m[WARN] %s ", __FUNCTION__, "%s", "stubbed"); | 
        ||
| 62 | |||
| 63 | #define STUB_ONCE()                                                          \ | 
        ||
| 64 |     static int stub_printed = 0;                                             \ | 
        ||
| 65 |     if (!stub_printed) {                                                     \ | 
        ||
| 66 |         debug_printf("\033[0;31m[WARN] %s ", __FUNCTION__, "%s", "stubbed"); \ | 
        ||
| 67 |         stub_printed = 1;                                                    \ | 
        ||
| 68 |     } | 
        ||
| 69 | |||
| 70 | // int count_open_fds(); | 
        ||
| 71 | |||
| 72 | #endif |