Classes | Public Member Functions | Static Public Member Functions | Private Attributes | Static Private Attributes | List of all members
dynamicgraph::RealTimeLogger Class Reference

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

#include <real-time-logger-def.h>


struct  Data
struct  thread

Public Member Functions

void addOutputStream (const LoggerStreamPtr_t &os)
void clearOutputStreams ()
bool empty () const
RTLoggerStream emptyStream ()
 Return an empty stream object. More...
RTLoggerStream front ()
void frontReady ()
bool full () const
std::size_t getBufferSize ()
 RealTimeLogger (const std::size_t &bufferSize)
std::size_t size () const
bool spinOnce ()
 ~RealTimeLogger ()

Static Public Member Functions

static void destroy ()
static RealTimeLoggerinstance ()

Private Attributes

std::size_t backIdx_
std::vector< Data * > buffer_
std::size_t frontIdx_
 Index of the next value to be read. More...
std::size_t nbDiscarded_
std::ostream oss_
std::vector< LoggerStreamPtr_toutputs_
boost::mutex wmutex
 The writer mutex. More...

Static Private Attributes

static RealTimeLoggerinstance_ = NULL
static threadthread_ = NULL

Detailed Description

Main class of the real-time logger.

It is intended to be used like this:

// 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."
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 96 of file real-time-logger-def.h.

Constructor & Destructor Documentation

◆ RealTimeLogger()

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

Definition at line 15 of file src/debug/real-time-logger.cpp.

◆ ~RealTimeLogger()

dynamicgraph::RealTimeLogger::~RealTimeLogger ( )

Definition at line 24 of file src/debug/real-time-logger.cpp.

Member Function Documentation

◆ addOutputStream()

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

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

◆ clearOutputStreams()

void dynamicgraph::RealTimeLogger::clearOutputStreams ( )

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

◆ destroy()

void dynamicgraph::RealTimeLogger::destroy ( )

Definition at line 129 of file src/debug/real-time-logger.cpp.

◆ empty()

bool dynamicgraph::RealTimeLogger::empty ( ) const

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

◆ emptyStream()

RTLoggerStream dynamicgraph::RealTimeLogger::emptyStream ( )

Return an empty stream object.

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

◆ 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.

Definition at line 42 of file src/debug/real-time-logger.cpp.

◆ frontReady()

void dynamicgraph::RealTimeLogger::frontReady ( )

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

◆ full()

bool dynamicgraph::RealTimeLogger::full ( ) const

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

◆ getBufferSize()

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

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

◆ instance()

RealTimeLogger & dynamicgraph::RealTimeLogger::instance ( )

Definition at line 121 of file src/debug/real-time-logger.cpp.

◆ size()

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

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

◆ spinOnce()

bool dynamicgraph::RealTimeLogger::spinOnce ( )

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

true if it wrote something

Definition at line 29 of file src/debug/real-time-logger.cpp.

Member Data Documentation

◆ backIdx_

std::size_t dynamicgraph::RealTimeLogger::backIdx_

Index of the slot where to write next value (does not contain valid data).

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

◆ buffer_

std::vector<Data *> dynamicgraph::RealTimeLogger::buffer_

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

◆ frontIdx_

std::size_t dynamicgraph::RealTimeLogger::frontIdx_

Index of the next value to be read.

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

◆ instance_

RealTimeLogger * dynamicgraph::RealTimeLogger::instance_ = NULL

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

◆ nbDiscarded_

std::size_t dynamicgraph::RealTimeLogger::nbDiscarded_

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

◆ oss_

std::ostream dynamicgraph::RealTimeLogger::oss_

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

◆ outputs_

std::vector<LoggerStreamPtr_t> dynamicgraph::RealTimeLogger::outputs_

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

◆ thread_

RealTimeLogger::thread * dynamicgraph::RealTimeLogger::thread_ = NULL

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

◆ wmutex

boost::mutex dynamicgraph::RealTimeLogger::wmutex

The writer mutex.

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

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

Author(s): Nicolas Mansard, Olivier Stasse
autogenerated on Sun Jun 25 2023 02:06:03