debug_log.h (1546B)
1 #ifndef DEBUG_LOG_H_ 2 #define DEBUG_LOG_H_ 3 4 #define DEBUG_LOG_CAPACITY_CHUNK 255 5 #define DEBUG_LOG_CAPACITY_DESCRIPTION 255 6 7 #define DEBUG_LOG_LEVEL_CRITICAL 127 8 #define DEBUG_LOG_LEVEL_WARNING 64 9 #define DEBUG_LOG_LEVEL_MESSAGE -1 10 #define DEBUG_LOG_LEVEL_DEBUG -64 11 #define DEBUG_LOG_LEVEL_ALL -128 12 13 typedef struct /*debug_log_item_t*/ { 14 unsigned long ns; 15 char level; 16 char *origin; 17 char *description; 18 } debug_log_item_t; 19 20 21 typedef struct /*lash_debug_log_t*/ { 22 unsigned long ns_start; 23 unsigned short int count; 24 unsigned short int capacity; 25 debug_log_item_t *items; 26 char *error_string_buffer; // used for sprintf, if no description in item is set the current error string buffer is used instead 27 char *origin_string_buffer; // used for sprintf, if no description in item is set the current error string buffer is used instead 28 int autoflush; 29 } debug_log_t; 30 31 #ifndef alog 32 #define alog 1; 33 debug_log_t logobj; 34 #line 31 __FILE__ 35 #define loglevel(x) debugLogInit(&logobj, 1) 36 #define logset(c, s) debugLogSetDescription(&logobj, s); debugLogSetOrigin(&logobj, c); 37 #define logadd(l) debugLogAdd(&logobj, NULL, l, NULL); 38 #endif //lash_log 39 40 #ifdef LASH_DEBUG_LOG_GLOBAL 41 #include <stdio.h> 42 debug_log_t log_global; 43 #endif 44 45 #ifdef __cplusplus 46 extern "C" { 47 #endif 48 int debugLogInit(debug_log_t *log, int autoflush); 49 int debugLogAdd(debug_log_t *log, char *origin, char level, char *description); 50 int debugLogSetDescription(debug_log_t *log, const char *d); 51 int debugLogSetOrigin(debug_log_t *log, const char *o); 52 53 #ifdef __cplusplus 54 } 55 #endif 56 57 #endif