root/include/debug.h

/* [<][>][^][v][top][bottom][index][help] */
   1 #ifndef DEBUG_H
   2 #define DEBUG_H
   3 
   4 
   5 // 1 mean do logging and profiling, 0 mean release version
   6 #define DEBUG_LOGS 1
   7 #define DEBUG_PROF 0
   8 
   9 // Simple logger functions
  10 
  11 void debug_open( char* filefmt);
  12 void debug_flush( int forcesave );
  13 void debug_close();
  14 void debug_print( char* str );
  15 void debug_print_int( char *fmt, int val );
  16 void debug_print_float( char *fmt, float val );
  17 
  18 // Profiler functions
  19 
  20 void debug_profiler_start();
  21 void debug_profiler_resume();
  22 void debug_profiler_stop();
  23 void debug_profiler_flush(int forcesave);
  24 
  25 void debug_profiler(const char* filename,int line, const char* function, const char* arg);
  26 void debug_profiler_print(const char* str);
  27 
  28 #ifdef DEBUG_LOGS
  29 #define DOPEN(s) debug_open(s)
  30 #define DCLOSE debug_close()
  31 #define DLOG_STR(s) debug_print(s)
  32 #define DLOG_INT(s,v) debug_print_int(s,v)
  33 #define DLOG_FLOAT(s,v) debug_print_float(s,v)
  34 #define DLOG_FLUSH debug_flush(1)
  35 #else
  36 #define DOPEN(s)
  37 #define DCLOSE 
  38 #define DLOG_STR(s) 
  39 #define DLOG_INT(s,v) 
  40 #define DLOG_FLOAT(s,v)
  41 #define DLOG_FLUSH
  42 #endif
  43 
  44 #ifdef DEBUG_PROF
  45 #define PROFILER(s) debug_profiler(__FILE__, __LINE__, __FUNCTION__, s) 
  46 #define PROFILERSTR(s) debug_profiler_print(s)
  47 #define PROFILERB(a) debug_profiler(__FILE__, __LINE__, __FUNCTION__, "b " #a) 
  48 #define PROFILERE(a) debug_profiler(__FILE__, __LINE__, __FUNCTION__, "e " #a)
  49 #else
  50 #define PROFILER(s)
  51 #define PROFILERSTR(s) 
  52 #define PROFILERB(a) 
  53 #define PROFILERE(a) 
  54 
  55 #endif
  56 
  57 // Usage sample           PROFILERB(gui_redraw); 
  58 
  59 #endif

/* [<][>][^][v][top][bottom][index][help] */