57 #include <visp3/core/vpConfig.h>
61 #define __FUNCTION__ " "
66 #define VP_DEBUG_MODE 0
140 const char *currentFile;
141 const char *currentFunc;
160 vpTraceOutput(
const char *file,
int line,
const char *func,
bool error =
false,
const char *s = NULL)
161 : currentFile(file), currentFunc(func), currentLine(line), err(error), header(s)
173 if (VP_DEBUG_MODE >= level) {
176 va_start(args, format);
179 std::cerr <<
"(L" << level <<
") ";
181 std::cout <<
"(L" << level <<
") ";
198 va_start(args, format);
201 std::cout <<
"(L0) ";
219 void display(
const char *format, va_list args)
227 std::cerr <<
"!!\t" << currentFile <<
": " << currentFunc <<
"(#" << currentLine <<
") : ";
229 vfprintf(stderr, format, args);
230 fprintf(stderr,
"\n");
238 std::cout << currentFile <<
": " << currentFunc <<
"(#" << currentLine <<
") : ";
240 vprintf(format, args);
275 #define vpIN_FCT (vpTraceOutput(__FILE__, __LINE__, __FUNCTION__, false, "begin "))
295 #define vpOUT_FCT (vpTraceOutput(__FILE__, __LINE__, __FUNCTION__, false, "end "))
299 inline void vpIN_FCT(
const char * , ...) {}
300 inline void vpOUT_FCT(
const char * , ...) {}
338 #define vpCTRACE std::cout << "(L0) " << __FILE__ << ": " << __FUNCTION__ << "(#" << __LINE__ << ") : "
366 std::cerr << "(L0) " \
367 << "!!\t" << __FILE__ << ": " << __FUNCTION__ << "(#" << __LINE__ << ") : "
393 #define vpERROR_TRACE (vpTraceOutput(__FILE__, __LINE__, __FUNCTION__, true))
416 #define vpTRACE (vpTraceOutput(__FILE__, __LINE__, __FUNCTION__, false))
429 inline void vpTRACE(
const char * , ...) {}
430 inline void vpTRACE(
int ,
const char * , ...) {}
464 #define vpDERROR_TRACE (vpTraceOutput(__FILE__, __LINE__, __FUNCTION__, true))
487 #define vpDEBUG_TRACE (vpTraceOutput(__FILE__, __LINE__, __FUNCTION__, false))
511 #define vpCDEBUG(level) \
512 if (VP_DEBUG_MODE < level) \
515 std::cout << "(L" << level << ") " << __FILE__ << ": " << __FUNCTION__ << "(#" << __LINE__ << ") : "
538 #define vpDEBUG_ENABLE(level) (VP_DEBUG_MODE >= level)
547 #define vpCDEBUG(level) \
550 #define vpDEBUG_ENABLE(level) (false)
561 #define DEFENSIF(a) (a)
563 #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)