Go to the documentation of this file.00001 #ifndef FCAM_DEBUG
00002 #define FCAM_DEBUG
00003
00011 #include <stdio.h>
00012 #include <stdarg.h>
00013
00014
00015
00016 #if defined(DEBUG) && !defined(FCAM_DEBUG_LEVEL)
00017
00024 #define FCAM_DEBUG_LEVEL 0
00025 #endif
00026
00030 enum debugLevel { DBG_ERROR=0,
00031 DBG_WARN=1,
00032 DBG_MAJOR=2,
00033 DBG_MINOR=3 };
00034
00036 #define STRX(x) #x
00037 #define STR(x) STRX(x)
00038
00039 #if defined(DEBUG)
00040
00044 inline void _dprintf(int level, const char *src, const char *fmt, ...) {
00045 if (level <= FCAM_DEBUG_LEVEL) {
00046 char buf[512];
00047
00048 va_list arglist;
00049 va_start(arglist, fmt);
00050 vsnprintf(buf, 512, fmt, arglist);
00051 va_end(arglist);
00052
00053 fprintf(stderr, "%*c(%d) %s: %s",level*2+2,' ',level,src, buf);
00054 }
00055 }
00056
00057 #else
00058
00062 inline void _dprintf(int, const char *, const char *, ...) {}
00063 #endif
00064
00066 #define dprintf(level, ...) _dprintf(level, __FILE__ ":" STR(__LINE__), __VA_ARGS__)
00067
00068 #endif