dynamicgraph::RealTimeLogger Class Reference

Main class of the real-time logger. More...

#include <dynamic-graph/real-time-logger-def.h>

Public Member Functions

 RealTimeLogger (const std::size_t &bufferSize)
 
void clearOutputStreams ()
 
void addOutputStream (const LoggerStreamPtr_t &os)
 
bool spinOnce ()
 Write next message to output. More...
 
RTLoggerStream front ()
 Return an object onto which a real-time thread can write. More...
 
RTLoggerStream emptyStream ()
 Return an empty stream object. More...
 
void frontReady ()
 
bool empty () const
 
bool full () const
 
std::size_t size () const
 
std::size_t getBufferSize ()
 
 ~RealTimeLogger ()
 

Static Public Member Functions

static RealTimeLoggerinstance ()
 
static void destroy ()
 

Detailed Description

Main class of the real-time logger.

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) {
}
// Somewhere in your library
dgRTLOG() << "your message. Prefer to use \n than std::endl."
Note
Thread safety. This class expects to have:
  • only one reader: the one who take the log entries and write them somewhere.
  • one writer at a time. Writing to the logs is **never** a blocking operation. If the resource is busy, the log entry is discarded.

Constructor & Destructor Documentation

◆ RealTimeLogger()

dynamicgraph::RealTimeLogger::RealTimeLogger ( const std::size_t &  bufferSize)
Todo:
add an argument to preallocate the internal string to a given size.

◆ ~RealTimeLogger()

dynamicgraph::RealTimeLogger::~RealTimeLogger ( )

Member Function Documentation

◆ addOutputStream()

void dynamicgraph::RealTimeLogger::addOutputStream ( const LoggerStreamPtr_t os)
inline

◆ clearOutputStreams()

void dynamicgraph::RealTimeLogger::clearOutputStreams ( )
inline

◆ destroy()

static void dynamicgraph::RealTimeLogger::destroy ( )
static

◆ empty()

bool dynamicgraph::RealTimeLogger::empty ( ) const
inline

◆ emptyStream()

RTLoggerStream dynamicgraph::RealTimeLogger::emptyStream ( )
inline

Return an empty stream object.

Referenced by dynamicgraph::Logger::stream().

◆ front()

RTLoggerStream dynamicgraph::RealTimeLogger::front ( )

Return an object onto which a real-time thread can write.

The message is considered finished when the object is destroyed.

Referenced by dynamicgraph::Logger::stream().

◆ frontReady()

void dynamicgraph::RealTimeLogger::frontReady ( )
inline

Referenced by getBufferSize().

◆ full()

bool dynamicgraph::RealTimeLogger::full ( ) const
inline

◆ getBufferSize()

std::size_t dynamicgraph::RealTimeLogger::getBufferSize ( )
inline

References frontReady().

◆ instance()

static RealTimeLogger& dynamicgraph::RealTimeLogger::instance ( )
static

◆ size()

std::size_t dynamicgraph::RealTimeLogger::size ( ) const
inline

◆ spinOnce()

bool dynamicgraph::RealTimeLogger::spinOnce ( )

Write next message to output.

It does nothing if the buffer is empty.

Returns
true if it wrote something