All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Loggers

Initialization of the logger

Header and preprocessor variable

In order to activate the logger you need to add the following lines:

#define ENABLE_RT_LOG

Initialize the output stream

It is possible to set the output stream of the messages inside a file:

of.open("/tmp/dg-LOGS.txt",std::ofstream::out|std::ofstream::app);

Here the file is "/tmp/dg-LOGS.txt".

Initialization of the logger

Inside the constructor of the entity:

logger_.setTimeSample(0.001);
logger_.setStreamPrintPeriod(0.005);
logger_.setVerbosity(VERBOSITY_ALL);
LoggerVerbosity alv = logger_.getVerbosity();

The first line sets the frequency at which the logger will be updated.
The second line specifies at which frequency the message should be printed.
The third line specifies the level of message to accept.
The fourth line returns the level of verbosity. In this case, all messages are accepted.

The full list of options are:

  • VERBOSITY_ALL: Accept all messages
  • VERBOSITY_INFO_WARNING_ERROR: Accept messages at minimum level : INFO, WARNING, ERROR
  • VERBOSITY_WARNING_ERROR: Accept messages at minimum level : WARNING, ERROR
  • VERBOSITY_ERROR: Accept messages at minimum level : ERROR

Displaying messages

Here is some example on how to display or record some information.

sendMsg("This is a message of level MSG_TYPE_DEBUG",MSG_TYPE_DEBUG);
sendMsg("This is a message of level MSG_TYPE_INFO",MSG_TYPE_INFO);
sendMsg("This is a message of level MSG_TYPE_WARNING",MSG_TYPE_WARNING);
sendMsg("This is a message of level MSG_TYPE_ERROR",MSG_TYPE_ERROR);
sendMsg("This is a message of level MSG_TYPE_DEBUG_STREAM",MSG_TYPE_DEBUG_STREAM);
sendMsg("This is a message of level MSG_TYPE_INFO_STREAM",MSG_TYPE_INFO_STREAM);
sendMsg("This is a message of level MSG_TYPE_WARNING_STREAM",MSG_TYPE_WARNING_STREAM);
sendMsg("This is a message of level MSG_TYPE_ERROR_STREAM",MSG_TYPE_ERROR_STREAM);
logger_.countdown();