Visual Servoing Platform  version 3.6.1 under development (2024-11-15)
tutorial-trace.cpp
1 
2 //#define VP_TRACE // Activate the trace mode
3 //#define VP_DEBUG // Activate the debug mode
4 #define VP_DEBUG_MODE 2 // Activate debug level 1 and 2
5 
6 #include <visp3/core/vpConfig.h>
7 #include <visp3/core/vpDebug.h>
8 
9 int main()
10 {
11 #ifdef ENABLE_VISP_NAMESPACE
12  using namespace VISP_NAMESPACE_NAME;
13 #endif
14 
15  vpIN_FCT("main()"); // std::cout if VP_TRACE defined
16 
17  // Check the active debug levels set in VP_DEBUG_MODE
18  std::cout << "Debug level 1 active: " << vpDEBUG_ENABLE(1) << std::endl;
19  std::cout << "Debug level 2 active: " << vpDEBUG_ENABLE(2) << std::endl;
20  std::cout << "Debug level 3 active: " << vpDEBUG_ENABLE(3) << std::endl;
21 
22  // C-like trace printings if VP_TRACE defined
23  vpTRACE("C-like trace"); // std::cout
24  vpTRACE(1, "C-like trace level 1"); // std::cout
25 
26  vpERROR_TRACE("C-like error trace"); // std::cerr
27  vpERROR_TRACE(1, "C-like error trace level 1"); // std::cerr if
28  // VP_DEBUG_MODE value is >=
29  // 1
30 
31  // C-like debug printings if VP_DEBUG defined
32  vpDEBUG_TRACE("C-like debug trace"); // stdout
33  vpDERROR_TRACE("C-like error trace"); // stderr
34 
35  vpDEBUG_TRACE(2,
36  "C-like debug trace level 2"); // std::cout if VP_DEBUG_MODE value >= 2
37  vpDERROR_TRACE(2,
38  "C-like error trace level 2"); // std::cerr if VP_DEBUG_MODE value >= 2
39 
40  // C++-like trace printings if VP_TRACE defined
41  vpCTRACE << "C++-like trace" << std::endl; // std::cout
42  vpCERROR << "C++-like error trace" << std::endl; // std::cerr
43 
44  // C++-like debug printings if VP_DEBUG defined
45  vpCDEBUG(2) << "C++-like debug trace level 2" << std::endl; // std::cout if VP_DEBUG_MODE value >= 2
46 
47  vpOUT_FCT("main()"); // std::cout if VP_TRACE defined
48 }