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 }
entity.h
dynamicgraph::Logger::setTimeSample
bool setTimeSample(double t)
Definition: logger.cpp:53
dynamicgraph::Logger::countdown
void countdown()
Definition: logger.cpp:37
dynamicgraph::CustomEntity::getClassName
virtual const std::string & getClassName() const
Definition: debug-logger-winit.cpp:37
dynamicgraph::Logger::setStreamPrintPeriod
bool setStreamPrintPeriod(double s)
Definition: logger.cpp:59
dynamicgraph::MSG_TYPE_DEBUG_STREAM
@ MSG_TYPE_DEBUG_STREAM
Definition: logger.h:37
logger.h
dynamicgraph::LoggerVerbosity
LoggerVerbosity
Definition: logger.h:143
dynamicgraph
dynamicgraph::CustomEntity::~CustomEntity
~CustomEntity()
Definition: debug-logger-winit.cpp:46
dynamicgraph::Logger::setVerbosity
void setVerbosity(LoggerVerbosity lv)
Definition: logger.cpp:34
dynamicgraph::Entity::sendMsg
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.
Definition: src/dgraph/entity.cpp:215
dynamicgraph::Entity
This class represents an entity, i.e. a generic computational unit that provides input and output sig...
Definition: include/dynamic-graph/entity.h:52
dynamicgraph::MSG_TYPE_WARNING_STREAM
@ MSG_TYPE_WARNING_STREAM
Definition: logger.h:39
dynamicgraph::DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(CustomEntity, "CustomEntity")
dynamicgraph::CustomEntity
Definition: command-test.cpp:36
dynamicgraph::MSG_TYPE_WARNING
@ MSG_TYPE_WARNING
Definition: logger.h:35
dynamicgraph::MSG_TYPE_INFO
@ MSG_TYPE_INFO
Definition: logger.h:34
dynamicgraph::CustomEntity::CustomEntity
CustomEntity(const std::string &n)
Definition: debug-logger-winit.cpp:38
dynamicgraph::MSG_TYPE_ERROR
@ MSG_TYPE_ERROR
Definition: logger.h:36
CustomEntity
Definition: custom-entity.cpp:22
dynamicgraph::CustomEntity::testDebugTrace
void testDebugTrace()
Definition: debug-logger-winit.cpp:47
dynamicgraph::Logger::getVerbosity
LoggerVerbosity getVerbosity()
Definition: logger.cpp:36
BOOST_AUTO_TEST_CASE
BOOST_AUTO_TEST_CASE(debug_logger_wrong_initialization)
Definition: debug-logger-winit.cpp:67
dynamicgraph::Entity::logger_
Logger logger_
Definition: include/dynamic-graph/entity.h:177
dynamicgraph::Entity::Entity
Entity(const std::string &name)
Definition: src/dgraph/entity.cpp:33
dynamicgraph::MSG_TYPE_ERROR_STREAM
@ MSG_TYPE_ERROR_STREAM
Definition: logger.h:40
exception-factory.h
factory.h
dynamicgraph::MSG_TYPE_DEBUG
@ MSG_TYPE_DEBUG
Definition: logger.h:33
dynamicgraph::CustomEntity::CLASS_NAME
static const std::string CLASS_NAME
Definition: command-test.cpp:38
dynamicgraph::VERBOSITY_ALL
@ VERBOSITY_ALL
Definition: logger.h:144
dynamicgraph::RealTimeLogger::destroy
static void destroy()
Definition: src/debug/real-time-logger.cpp:129
real-time-logger.h
dynamicgraph::RealTimeLogger::instance
static RealTimeLogger & instance()
Definition: src/debug/real-time-logger.cpp:121
dynamicgraph::MSG_TYPE_INFO_STREAM
@ MSG_TYPE_INFO_STREAM
Definition: logger.h:38
dynamicgraph::FactoryStorage::newEntity
Entity * newEntity(const std::string &classname, const std::string &objname) const
Instantiate (and allocate) an entity.
Definition: src/dgraph/factory.cpp:79
pool.h
dynamicgraph::FactoryStorage::getInstance
static FactoryStorage * getInstance()
Get pointer to unique object of the class.
Definition: src/dgraph/factory.cpp:15


dynamic-graph
Author(s): Nicolas Mansard, Olivier Stasse
autogenerated on Sun Oct 22 2023 02:27:08