|
| 1 | +/** |
| 2 | +\page subp_logger Loggers |
| 3 | +
|
| 4 | +\section sec_logger Initialization of the logger |
| 5 | +
|
| 6 | +\subsection subsec_logger_hcpp Header and preprocessor variable |
| 7 | +
|
| 8 | +In order to activate the logger you need to add the following lines: |
| 9 | +\code |
| 10 | +#define ENABLE_RT_LOG |
| 11 | +#include <dynamic-graph/real-time-logger.h> |
| 12 | +#include <dynamic-graph/logger.h> |
| 13 | +\endcode |
| 14 | +
|
| 15 | +\subsection subsec_logger_ Initialize the output stream |
| 16 | +
|
| 17 | +It is possible to set the output stream of the messages inside a file: |
| 18 | +\code |
| 19 | + dynamicgraph::RealTimeLogger::instance(); |
| 20 | + of.open("/tmp/dg-LOGS.txt",std::ofstream::out|std::ofstream::app); |
| 21 | + dgADD_OSTREAM_TO_RTLOG (of); |
| 22 | + |
| 23 | + dynamicgraph::RealTimeLogger::destroy(); |
| 24 | +\endcode |
| 25 | +Here the file is "/tmp/dg-LOGS.txt". |
| 26 | +
|
| 27 | +\subsection subsec_logger_init Initialization of the logger |
| 28 | +
|
| 29 | +Inside the constructor of the entity: |
| 30 | +\code |
| 31 | + logger_.setTimeSample(0.001); |
| 32 | + logger_.setStreamPrintPeriod(0.005); |
| 33 | + logger_.setVerbosity(VERBOSITY_ALL); |
| 34 | + LoggerVerbosity alv = logger_.getVerbosity(); |
| 35 | +\endcode |
| 36 | +
|
| 37 | +The first line sets the frequency at which the logger will be updated.<br> |
| 38 | +The second line specifies at which frequency the message should be |
| 39 | +printed.<br> |
| 40 | +The third line specifies the level of message to accept.<br> |
| 41 | +The fourth line returns the level of verbosity. |
| 42 | +In this case, all messages are accepted. <br> |
| 43 | +
|
| 44 | +The full list of options are: |
| 45 | +<ul> |
| 46 | +<li>VERBOSITY_ALL: Accept all messages</li> |
| 47 | +<li>VERBOSITY_INFO_WARNING_ERROR: Accept messages at minimum level : INFO, WARNING, ERROR</li> |
| 48 | +<li>VERBOSITY_WARNING_ERROR: Accept messages at minimum level : WARNING, ERROR</li> |
| 49 | +<li>VERBOSITY_ERROR: Accept messages at minimum level : ERROR</li> |
| 50 | +</ul> |
| 51 | +
|
| 52 | +
|
| 53 | +\section sec_logger_tests Displaying messages |
| 54 | +
|
| 55 | +Here is some example on how to display or record some information. |
| 56 | +\code |
| 57 | + sendMsg("This is a message of level MSG_TYPE_DEBUG",MSG_TYPE_DEBUG); |
| 58 | + sendMsg("This is a message of level MSG_TYPE_INFO",MSG_TYPE_INFO); |
| 59 | + sendMsg("This is a message of level MSG_TYPE_WARNING",MSG_TYPE_WARNING); |
| 60 | + sendMsg("This is a message of level MSG_TYPE_ERROR",MSG_TYPE_ERROR); |
| 61 | + sendMsg("This is a message of level MSG_TYPE_DEBUG_STREAM",MSG_TYPE_DEBUG_STREAM); |
| 62 | + sendMsg("This is a message of level MSG_TYPE_INFO_STREAM",MSG_TYPE_INFO_STREAM); |
| 63 | + sendMsg("This is a message of level MSG_TYPE_WARNING_STREAM",MSG_TYPE_WARNING_STREAM); |
| 64 | + sendMsg("This is a message of level MSG_TYPE_ERROR_STREAM",MSG_TYPE_ERROR_STREAM); |
| 65 | +
|
| 66 | + logger_.countdown(); |
| 67 | +\endcode |
| 68 | +*/ |
0 commit comments