54 #include <visp/vpConfig.h>
62 # define __FUNCTION__ " "
67 # define VP_DEBUG_MODE 0
142 const char* currentFile;
143 const char* currentFunc;
161 vpTraceOutput(
const char* file,
int line,
const char* func,
bool error=
false,
const char * s=NULL) :
177 if(VP_DEBUG_MODE >= level)
181 va_start(args, format);
184 std::cerr <<
"(L" << level <<
") " ;
186 std::cout <<
"(L" << level <<
") " ;
203 va_start(args, format);
224 void display(
const char* format, va_list args)
230 if(header != NULL) std::cerr<<header;
232 std::cerr <<
"!!\t" << currentFile <<
": " <<currentFunc <<
"(#" << currentLine <<
") : " ;
234 vfprintf (stderr, format, args);
235 fprintf (stderr,
"\n");
242 if(header != NULL) std::cout<<header;
244 std::cout <<currentFile <<
": " << currentFunc <<
"(#" << currentLine <<
") : " ;
246 vprintf (format, args);
260 #ifdef VP_TRACE // Activate the trace mode
280 #define vpIN_FCT (vpTraceOutput(__FILE__,__LINE__, __FUNCTION__, false, "begin "))
301 #define vpOUT_FCT (vpTraceOutput(__FILE__,__LINE__, __FUNCTION__, false, "end "))
303 #else // #ifdef VP_TRACE
305 inline void vpIN_FCT (
const char * , ...){}
306 inline void vpOUT_FCT (
const char * , ...){}
308 #endif // #ifdef VP_TRACE
341 #define vpCTRACE std::cout << "(L0) " << __FILE__ << ": " << __FUNCTION__ << "(#" << __LINE__ << ") : "
369 #define vpCERROR std::cerr << "(L0) " << "!!\t" << __FILE__ << ": " << __FUNCTION__ << "(#" << __LINE__ << ") : "
395 #define vpERROR_TRACE (vpTraceOutput( __FILE__,__LINE__, __FUNCTION__, true))
418 #define vpTRACE (vpTraceOutput( __FILE__,__LINE__, __FUNCTION__, false))
420 #else // #ifdef VP_TRACE
422 #define vpCTRACE if(false) std::cout // Warning C4127
423 #define vpCERROR if(false) std::cerr // Warning C4127
427 inline void vpTRACE (
const char * , ...){}
428 inline void vpTRACE (
int ,
const char * , ...){}
430 #endif // #ifdef VP_TRACE
459 #define vpDERROR_TRACE (vpTraceOutput( __FILE__,__LINE__, __FUNCTION__, true))
482 #define vpDEBUG_TRACE (vpTraceOutput( __FILE__,__LINE__, __FUNCTION__, false))
506 #define vpCDEBUG(level) if (VP_DEBUG_MODE < level) ; else \
507 std::cout << "(L" << level << ") "<< __FILE__ << ": " << __FUNCTION__ << "(#" << __LINE__ << ") : "
530 #define vpDEBUG_ENABLE(level) (VP_DEBUG_MODE >= level)
532 #else // #ifdef VP_DEBUG
539 #define vpCDEBUG(level) if(false) std::cout // Warning C4127
540 #define vpDEBUG_ENABLE(level) (false) // Warning C4127
542 #endif // #ifdef VP_DEBUG
548 #define DEFENSIF(a) (a)
550 #define DEFENSIF(a) (0)
This class is used to display debug or error messages.
vpTraceOutput(const char *file, int line, const char *func, bool error=false, const char *s=NULL)
void operator()(const char *format,...)
void operator()(int level, const char *format,...)
void display(const char *format, va_list args)