debug-logger-winit.cpp
Go to the documentation of this file.
1 /* Copyright 2019, LAAS-CNRS
2  *
3  * Olivier Stasse
4  *
5  * See LICENSE file
6  *
7  */
8 #include <iostream>
9 #include <sstream>
10 
11 #define ENABLE_RT_LOG
12 #include <dynamic-graph/entity.h>
14 #include <dynamic-graph/logger.h>
16 
17 #include "dynamic-graph/factory.h"
18 #include "dynamic-graph/pool.h"
19 
20 #define BOOST_TEST_MODULE debug - logger
21 
22 #if BOOST_VERSION >= 105900
23 #include <boost/test/tools/output_test_stream.hpp>
24 #else
25 #include <boost/test/output_test_stream.hpp>
26 #endif
27 #include <boost/date_time/posix_time/posix_time.hpp>
28 #include <boost/test/unit_test.hpp>
29 #include <boost/thread/thread.hpp>
30 
31 using boost::test_tools::output_test_stream;
32 
33 namespace dynamicgraph {
34 class CustomEntity : public Entity {
35  public:
36  static const std::string CLASS_NAME;
37  virtual const std::string &getClassName() const { return CLASS_NAME; }
38  explicit CustomEntity(const std::string &n) : Entity(n) {
39  logger_.setTimeSample(0.001);
43  BOOST_CHECK(alv == VERBOSITY_ALL);
44  }
45 
47  void testDebugTrace() {
48  sendMsg("This is a message of level MSG_TYPE_DEBUG", MSG_TYPE_DEBUG);
49  sendMsg("This is a message of level MSG_TYPE_INFO", MSG_TYPE_INFO);
50  sendMsg("This is a message of level MSG_TYPE_WARNING", MSG_TYPE_WARNING);
51  sendMsg("This is a message of level MSG_TYPE_ERROR", MSG_TYPE_ERROR);
52  sendMsg("This is a message of level MSG_TYPE_DEBUG_STREAM",
54  sendMsg("This is a message of level MSG_TYPE_INFO_STREAM",
56  sendMsg("This is a message of level MSG_TYPE_WARNING_STREAM",
58  sendMsg("This is a message of level MSG_TYPE_ERROR_STREAM",
60 
62  }
63 };
65 } // namespace dynamicgraph
66 
67 BOOST_AUTO_TEST_CASE(debug_logger_wrong_initialization) {
69 
70  BOOST_CHECK_EQUAL(dynamicgraph::CustomEntity::CLASS_NAME, "CustomEntity");
71 
73  *(dynamic_cast<dynamicgraph::CustomEntity *>(
75  "CustomEntity", "my-entity-2")));
76 
77  for (unsigned int i = 0; i < 1000; i++) {
78  entity.testDebugTrace();
79  }
80 
82 }
This class represents an entity, i.e. a generic computational unit that provides input and output sig...
void sendMsg(const std::string &msg, MsgType t=MSG_TYPE_INFO, const std::string &lineId="")
Send messages msg with level t. Add string file and line to message.
BOOST_AUTO_TEST_CASE(debug_logger_wrong_initialization)
static const std::string CLASS_NAME
virtual const std::string & getClassName() const
bool setTimeSample(double t)
Definition: logger.cpp:53
void setVerbosity(LoggerVerbosity lv)
Definition: logger.cpp:34
bool setStreamPrintPeriod(double s)
Definition: logger.cpp:59
CustomEntity(const std::string &n)
Entity(const std::string &name)
LoggerVerbosity getVerbosity()
Definition: logger.cpp:36
Entity * newEntity(const std::string &classname, const std::string &objname) const
Instantiate (and allocate) an entity.
static FactoryStorage * getInstance()
Get pointer to unique object of the class.
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(CustomEntity, "CustomEntity")


dynamic-graph
Author(s): Nicolas Mansard, Olivier Stasse
autogenerated on Sun Jun 25 2023 02:06:03