52 #include <visp3/core/vpConfig.h>
56 #define __FUNCTION__ " "
61 #define VP_DEBUG_MODE 0
150 vpTraceOutput(
const char *file,
int line,
const char *func,
bool error =
false,
const char *s =
nullptr)
151 : currentFile(file), currentFunc(func), currentLine(line), err(error), header(s)
162 if (VP_DEBUG_MODE >= level) {
165 va_start(args, format);
168 std::cerr <<
"(L" << level <<
") ";
171 std::cout <<
"(L" << level <<
") ";
189 va_start(args, format);
192 std::cout <<
"(L0) ";
210 void display(
const char *format, va_list args)
215 if (header !=
nullptr) {
219 std::cerr <<
"!!\t" << currentFile <<
": " << currentFunc <<
"(#" << currentLine <<
") : ";
221 vfprintf(stderr, format, args);
222 fprintf(stderr,
"\n");
228 if (header !=
nullptr) {
232 std::cout << currentFile <<
": " << currentFunc <<
"(#" << currentLine <<
") : ";
234 vprintf(format, args);
241 const char *currentFile;
242 const char *currentFunc;
280 #define vpIN_FCT (vpTraceOutput(__FILE__, __LINE__, __FUNCTION__, false, "begin "))
304 #define vpOUT_FCT (vpTraceOutput(__FILE__, __LINE__, __FUNCTION__, false, "end "))
308 inline void vpIN_FCT(
const char * , ...) { }
309 inline void vpOUT_FCT(
const char * , ...) { }
348 #define vpCTRACE std::cout << "(L0) " << __FILE__ << ": " << __FUNCTION__ << "(#" << __LINE__ << ") : "
379 #define vpCERROR std::cerr << "(L0) " << "!!\t" << __FILE__ << ": " << __FUNCTION__ << "(#" << __LINE__ << ") : "
409 #define vpERROR_TRACE (vpTraceOutput(__FILE__, __LINE__, __FUNCTION__, true))
436 #define vpTRACE (vpTraceOutput(__FILE__, __LINE__, __FUNCTION__, false))
447 inline void vpERROR_TRACE(
const char * , ...) { }
448 inline void vpERROR_TRACE(
int ,
const char * , ...) { }
449 inline void vpTRACE(
const char * , ...) { }
450 inline void vpTRACE(
int ,
const char * , ...) { }
485 #define vpDERROR_TRACE (vpTraceOutput(__FILE__, __LINE__, __FUNCTION__, true))
512 #define vpDEBUG_TRACE (vpTraceOutput(__FILE__, __LINE__, __FUNCTION__, false))
540 #define vpCDEBUG(level) \
541 if (VP_DEBUG_MODE < level) \
544 std::cout << "(L" << level << ") " << __FILE__ << ": " << __FUNCTION__ << "(#" << __LINE__ << ") : "
571 #define vpDEBUG_ENABLE(level) (VP_DEBUG_MODE >= level)
575 inline void vpDERROR_TRACE(
const char * , ...) { }
576 inline void vpDEBUG_TRACE(
const char * , ...) { }
577 inline void vpDERROR_TRACE(
int ,
const char * , ...) { }
578 inline void vpDEBUG_TRACE(
int ,
const char * , ...) { }
580 #define vpCDEBUG(level) \
583 #define vpDEBUG_ENABLE(level) (false)
591 #define DEFENSIF(a) (a)
593 #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=nullptr)
void operator()(const char *format,...)
void operator()(int level, const char *format,...)
void display(const char *format, va_list args)