dynamicgraph::Logger Class Reference

Class for logging messages. More...

#include <dynamic-graph/logger.h>

Collaboration diagram for dynamicgraph::Logger:
[legend]

Public Member Functions

 Logger (double timeSample=0.001, double streamPrintPeriod=1.0)
 Constructor. More...
 
 ~Logger ()
 Destructor. More...
 
void countdown ()
 Method to be called at every control iteration to decrement the internal Logger's counter. More...
 
void sendMsg (std::string msg, MsgType type, const char *file="", int line=0)
 Print the specified message on standard output if the verbosity level allows it. More...
 
bool setTimeSample (double t)
 Set the sampling time at which the method countdown() is going to be called. More...
 
double getTimeSample ()
 Get the sampling time at which the method countdown() is going to be called. More...
 
bool setStreamPrintPeriod (double s)
 Set the time period for printing of streaming messages. More...
 
double getStreamPrintPeriod ()
 Get the time period for printing of streaming messages. More...
 
void setVerbosity (LoggerVerbosity lv)
 Set the verbosity level of the logger. More...
 
LoggerVerbosity getVerbosity ()
 Get the verbosity level of the logger. More...
 

Protected Member Functions

bool isStreamMsg (MsgType m)
 
bool isDebugMsg (MsgType m)
 
bool isInfoMsg (MsgType m)
 
bool isWarningMsg (MsgType m)
 
bool isErrorMsg (MsgType m)
 

Protected Attributes

LoggerVerbosity m_lv
 
double m_timeSample
 verbosity of the logger More...
 
double m_streamPrintPeriod
 specify the period of call of the countdown method More...
 
double m_printCountdown
 specify the time period of the stream prints More...
 
std::map< std::string, double > m_stream_msg_counters
 every time this is < 0 (i.e. every _streamPrintPeriod sec) print stuff More...
 

Detailed Description

Class for logging messages.

It is intended to be used like this:

#define ENABLE_RT_LOG
// Somewhere in the main function of your executable
int main (int argc, char** argv) {
std::ofstream of;
of.open("/tmp/dg-LOGS.txt",std::ofstream::out|std::ofstream::app);
}
// Somewhere in your library
dynamicgraph::LoggerVerbosity aLoggerVerbosityLevel =
entity.setLoggerVerbosityLevel(aLoggerVerbosityLevel);
...
std::string aMsg=aBaseMsg+" WARNING";
entity.sendMsg(aMsg,dynamicgraph::MSG_TYPE_WARNING, __FILE__,__LINE__);

Constructor & Destructor Documentation

◆ Logger()

dynamicgraph::Logger::Logger ( double  timeSample = 0.001,
double  streamPrintPeriod = 1.0 
)

Constructor.

◆ ~Logger()

dynamicgraph::Logger::~Logger ( )

Destructor.

Member Function Documentation

◆ countdown()

void dynamicgraph::Logger::countdown ( )

Method to be called at every control iteration to decrement the internal Logger's counter.

◆ getStreamPrintPeriod()

double dynamicgraph::Logger::getStreamPrintPeriod ( )

Get the time period for printing of streaming messages.

◆ getTimeSample()

double dynamicgraph::Logger::getTimeSample ( )

Get the sampling time at which the method countdown() is going to be called.

◆ getVerbosity()

LoggerVerbosity dynamicgraph::Logger::getVerbosity ( )

Get the verbosity level of the logger.

◆ isDebugMsg()

bool dynamicgraph::Logger::isDebugMsg ( MsgType  m)
inlineprotected

◆ isErrorMsg()

bool dynamicgraph::Logger::isErrorMsg ( MsgType  m)
inlineprotected

◆ isInfoMsg()

bool dynamicgraph::Logger::isInfoMsg ( MsgType  m)
inlineprotected

◆ isStreamMsg()

◆ isWarningMsg()

bool dynamicgraph::Logger::isWarningMsg ( MsgType  m)
inlineprotected

◆ sendMsg()

void dynamicgraph::Logger::sendMsg ( std::string  msg,
MsgType  type,
const char *  file = "",
int  line = 0 
)

Print the specified message on standard output if the verbosity level allows it.

The file name and the line number are used to identify the point where sendMsg is called so that streaming messages are printed only every streamPrintPeriod iterations.

◆ setStreamPrintPeriod()

bool dynamicgraph::Logger::setStreamPrintPeriod ( double  s)

Set the time period for printing of streaming messages.

◆ setTimeSample()

bool dynamicgraph::Logger::setTimeSample ( double  t)

Set the sampling time at which the method countdown() is going to be called.

◆ setVerbosity()

void dynamicgraph::Logger::setVerbosity ( LoggerVerbosity  lv)

Set the verbosity level of the logger.

Member Data Documentation

◆ m_lv

LoggerVerbosity dynamicgraph::Logger::m_lv
protected

◆ m_printCountdown

double dynamicgraph::Logger::m_printCountdown
protected

specify the time period of the stream prints

◆ m_stream_msg_counters

std::map<std::string, double> dynamicgraph::Logger::m_stream_msg_counters
protected

every time this is < 0 (i.e. every _streamPrintPeriod sec) print stuff

Pointer to the dynamic structure which holds the collection of streaming messages

◆ m_streamPrintPeriod

double dynamicgraph::Logger::m_streamPrintPeriod
protected

specify the period of call of the countdown method

◆ m_timeSample

double dynamicgraph::Logger::m_timeSample
protected

verbosity of the logger