Visual Servoing Platform  version 3.2.0
vpTraceOutput Class Reference

#include <vpDebug.h>

Public Member Functions

 vpTraceOutput (const char *file, int line, const char *func, bool error=false, const char *s=NULL)
 
void operator() (int level, const char *format,...)
 
void operator() (const char *format,...)
 
void display (const char *format, va_list args)
 

Detailed Description

This class is used to display debug or error messages.

It needs to be initialized with the file name, function name and line, of the place where it is created. It is best used by first instanciating the object and directly calling the () operator. This is used to mimic variadic macros.

This class is used to define the following macros:

The example below shows how to use these macros.

#define VP_TRACE // Activate the trace mode
#define VP_DEBUG // Activate the debug mode
#define VP_DEBUG_MODE 2 // Activate debug level 1 and 2
#include <visp3/core/vpDebug.h>
int main()
{
vpIN_FCT("main()");
// Check the active debug levels
std::cout << "Debug level 1 active: " << vpDEBUG_ENABLE(1) << std::endl;
std::cout << "Debug level 2 active: " << vpDEBUG_ENABLE(2) << std::endl;
std::cout << "Debug level 3 active: " << vpDEBUG_ENABLE(3) << std::endl;
// C-like debug printings
vpTRACE("C-like trace"); // stdout
// Printing depend only VP_DEBUG_MODE value is >= 1
vpTRACE(1, "C-like trace level 1"); // stdout
vpERROR_TRACE(1, "C-like error trace level 1"); // stderr
// Printing if VP_DEBUG defined and VP_DEBUG_MODE value >= 2
vpDEBUG_TRACE(2, "C-like debug trace level 2"); // stdout
vpDERROR_TRACE(2, "C-like error trace level 2"); // stderr
// C++-like debug printings
vpCTRACE << "C++-like trace" << std::endl; // stdout
vpCERROR << "C++-like error trace" << std::endl; // stderr
// Printing if VP_DEBUG defined and VP_DEBUG_MODE value >= 2
vpCDEBUG(2) << "C++-like debug trace level 2" << std::endl; // stdout
vpOUT_FCT("main()");
}

Definition at line 136 of file vpDebug.h.

Constructor & Destructor Documentation

◆ vpTraceOutput()

vpTraceOutput::vpTraceOutput ( const char *  file,
int  line,
const char *  func,
bool  error = false,
const char *  s = NULL 
)
inline

Constructor.

Parameters
fileShould be the name of the file where this constructor was called.
lineShould be the line in file where this constructor was called.
funcShould be the name of the function where this constructor was called.
errorIf true, writes to the error stream.
sString to print before any other message (acts like a header).
Note
Call the constructor with something like vpTraceOutput(FILE,LINE, FUNCTION).

Definition at line 159 of file vpDebug.h.

Member Function Documentation

◆ display()

void vpTraceOutput::display ( const char *  format,
va_list  args 
)
inline

Displays a message to either stdout or stderr (based on error boolean).

Parameters
formatFormating string.
argsList of arguments.

Definition at line 218 of file vpDebug.h.

◆ operator()() [1/2]

void vpTraceOutput::operator() ( const char *  format,
  ... 
)
inline

Displays a string.

Parameters
formatFormating string.

Definition at line 193 of file vpDebug.h.

◆ operator()() [2/2]

void vpTraceOutput::operator() ( int  level,
const char *  format,
  ... 
)
inline

Displays a string if the debug level is inferior to VP_DEBUG_MODE.

Parameters
levelLevel of this message.
formatFormating string.

Definition at line 169 of file vpDebug.h.

vpOUT_FCT
#define vpOUT_FCT
Definition: vpDebug.h:294
vpIN_FCT
#define vpIN_FCT
Definition: vpDebug.h:274
vpCDEBUG
#define vpCDEBUG(level)
Definition: vpDebug.h:510
vpDERROR_TRACE
#define vpDERROR_TRACE
Definition: vpDebug.h:463
vpCERROR
#define vpCERROR
Definition: vpDebug.h:364
vpCTRACE
#define vpCTRACE
Definition: vpDebug.h:337
vpERROR_TRACE
#define vpERROR_TRACE
Definition: vpDebug.h:392
vpTRACE
#define vpTRACE
Definition: vpDebug.h:415
vpDEBUG_ENABLE
#define vpDEBUG_ENABLE(level)
Definition: vpDebug.h:537
vpDEBUG_TRACE
#define vpDEBUG_TRACE
Definition: vpDebug.h:486