dynamic-graph  4.1.0-8-gdab7-dirty
Dynamic graph library
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 addOutputStream (const LoggerStreamPtr_t &os)
 
void clearOutputStreams ()
 
bool empty () const
 
RTLoggerStream emptyStream ()
 Return an empty stream object.
 
RTLoggerStream front ()
 
void frontReady ()
 
bool full () const
 
std::size_t getBufferSize ()
 
std::size_t size () const
 
bool spinOnce ()
 

Static Public Member Functions

static void destroy ()
 
static RealTimeLoggerinstance ()
 

Detailed Description

Main class of the real-time logger.

It is intended to be used like this:

#define ENABLE_RT_LOG
#include <dynamic-graph/real-time-logger.h>
// Somewhere in the main function of your executable
int main (int argc, char** argv) {
dgADD_OSTREAM_TO_RTLOG (std::cout);
}
// 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.

Definition at line 98 of file real-time-logger-def.h.

Constructor & Destructor Documentation

◆ RealTimeLogger()

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

Member Function Documentation

◆ front()

RTLoggerStream front ( )

Return an object onto which a real-time thread can write. The message is considered finished when the object is destroyed.

◆ spinOnce()

bool spinOnce ( )

Write next message to output. It does nothing if the buffer is empty.

Returns
true if it wrote something

The documentation for this class was generated from the following file: