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 STREAM messages 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 and the STREAM message are displayed on the output streams once on five.

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, __FILE__,__LINE__);
sendMsg("This is a message of level MSG_TYPE_INFO",MSG_TYPE_INFO, __FILE__,__LINE__);
sendMsg("This is a message of level MSG_TYPE_WARNING",MSG_TYPE_WARNING, __FILE__,__LINE__);
sendMsg("This is a message of level MSG_TYPE_ERROR",MSG_TYPE_ERROR, __FILE__,__LINE__);
sendMsg("This is a message of level MSG_TYPE_DEBUG_STREAM",MSG_TYPE_DEBUG_STREAM, __FILE__,__LINE__);
sendMsg("This is a message of level MSG_TYPE_INFO_STREAM",MSG_TYPE_INFO_STREAM, __FILE__,__LINE__);
sendMsg("This is a message of level MSG_TYPE_WARNING_STREAM",MSG_TYPE_WARNING_STREAM, __FILE__,__LINE__);
sendMsg("This is a message of level MSG_TYPE_ERROR_STREAM",MSG_TYPE_ERROR_STREAM, __FILE__,__LINE__);
logger_.countdown();

Specifying the file with FILE and the line inside the file by LINE are necessary for the STREAM messages. Indeed they are indexed using the two values. As the default value are "" and 0 the counting will be confused.