SignalLogger
A library for signal logging.
signal_logger::SignalLoggerNone Class Reference

#include <SignalLoggerNone.hpp>

Inheritance diagram for signal_logger::SignalLoggerNone:
Inheritance graph

Public Member Functions

 SignalLoggerNone ()
 Constructor. More...
 
virtual ~SignalLoggerNone ()
 Destructor. More...
 
template<typename ValueType_ >
void add (const ValueType_ *const var, const std::string &name, const std::string &group=LOG_ELEMENT_DEFAULT_GROUP_NAME, const std::string &unit=LOG_ELEMENT_DEFAULT_UNIT, const std::size_t divider=LOG_ELEMENT_DEFAULT_DIVIDER, const LogElementAction action=LOG_ELEMENT_DEFAULT_ACTION, const std::size_t bufferSize=LOG_ELEMENT_DEFAULT_BUFFER_SIZE, const BufferType bufferType=LOG_ELEMENT_DEFAULT_BUFFER_TYPE)
 Add. More...
 
virtual void initLogger (const SignalLoggerOptions &options) override
 
virtual bool startLogger (bool updateLogger=false) override
 Starts the logger (enable collecting) More...
 
virtual bool stopLogger () override
 Stop the logger (disable collecting) More...
 
virtual bool restartLogger (bool updateLogger=false) override
 Stop and then restart the logger. More...
 
virtual bool updateLogger (const bool readScript=true, const std::string &scriptname="") override
 Update the logger. More...
 
virtual bool saveLoggerScript (const std::string &scriptName=LOGGER_DEFAULT_SCRIPT_FILENAME) override
 Save logger script. More...
 
virtual bool collectLoggerData () override
 Collect log data, read data and push it into the buffer. More...
 
virtual bool publishData () override
 Publish a single data point of every element from the buffer. More...
 
virtual bool saveLoggerData (const signal_logger::LogFileTypeSet &logfileTypes) override
 Save all the buffered data into a log file. More...
 
virtual bool stopAndSaveLoggerData (const signal_logger::LogFileTypeSet &logfileTypes) override
 Stop the logger and save all the buffered data into a log file. More...
 
- Public Member Functions inherited from signal_logger::SignalLoggerBase
 SignalLoggerBase ()
 
virtual ~SignalLoggerBase ()=default
 Destructor. More...
 
bool isRunning () const
 True if logger is running. More...
 
virtual bool cleanup ()
 Cleanup logger. More...
 
void setMaxLoggingTime (double maxLoggingTime)
 Set max logging time. More...
 
bool hasElement (const std::string &name)
 Checks if logger has a log element with name 'name'. More...
 
const LogElementInterfacegetElement (const std::string &name)
 Gets a const reference to a log element. More...
 
bool enableElement (const std::string &name)
 Enables the element if: More...
 
bool disableElement (const std::string &name)
 Disables element if logger is not running. More...
 
bool setElementBufferSize (const std::string &name, const std::size_t size)
 Sets buffer size of element if logger is not running. More...
 
bool setElementBufferType (const std::string &name, const BufferType type)
 Sets buffer type of element if logger is not running. More...
 
bool setElementDivider (const std::string &name, const std::size_t divider)
 Sets divider of element if logger is not running. More...
 
bool setElementAction (const std::string &name, const LogElementAction action)
 Sets action of element if logger is not running. More...
 
template<typename ValueType_ >
vector_type< ValueType_ > readNewValues (const std::string &name)
 Get new values (since the last call to this function) as a vector (first entry is the oldest) More...
 
bool enableNamespace (const std::string &ns)
 Property setting functions extended to namespace. More...
 
bool disableNamespace (const std::string &ns)
 
bool setNamespaceBufferSize (const std::string &ns, const std::size_t size)
 
bool setNamespaceBufferType (const std::string &ns, const BufferType type)
 
bool setNamespaceDivider (const std::string &ns, const std::size_t divider)
 
bool setNamespaceAction (const std::string &ns, const LogElementAction action)
 

Protected Member Functions

virtual bool workerSaveData (const std::string &logFileName, const signal_logger::LogFileTypeSet &logfileTypes) override
 Saves the logger data in a file in a seperate thread. More...
 
- Protected Member Functions inherited from signal_logger::SignalLoggerBase
bool readDataCollectScript (const std::string &scriptName)
 
bool saveDataCollectScript (const std::string &scriptName)
 
virtual void initTimeLogElement ()
 
virtual signal_logger::TimestampPair getCurrentTime ()
 
virtual bool hasElementLockFree (const std::string &name)
 Lock free version of has element. More...
 
virtual bool updateLoggerLockFree (const bool readScript=true, const std::string &scriptname="")
 Lock free version of updateLogger. More...
 

Additional Inherited Members

- Protected Types inherited from signal_logger::SignalLoggerBase
using LogPair = std::pair< std::string, std::unique_ptr< LogElementInterface > >
 Log element map types. More...
 
using LogElementMap = std::unordered_map< std::string, std::unique_ptr< LogElementInterface > >
 
using LogElementMapIterator = LogElementMap::iterator
 
- Protected Attributes inherited from signal_logger::SignalLoggerBase
SignalLoggerOptions options_
 Logger Options. More...
 
std::atomic_uint noCollectDataCalls_
 Nr of calls to collect data. More...
 
std::atomic_uint noCollectDataCallsCopy_
 Copy of nr of calls to collect data for saving. More...
 
LogElementMap logElements_
 Map of log elements (excluding time, elements added after last updateLogger() call) More...
 
std::vector< LogElementMapIteratorenabledElements_
 Vector of iterators in logElements_ map. More...
 
LogElementMap logElementsToAdd_
 Map of all log elements added since last call to updateLogger() More...
 
TimestampPair logTime_
 Time variable. More...
 
std::shared_ptr< LogElementBase< TimestampPair > > timeElement_
 Corresponding time log element. More...
 
std::atomic_bool isInitialized_
 Flag to check if logger is initialized. More...
 
std::atomic_bool isCollectingData_
 Flag to collect data. More...
 
std::atomic_bool isSavingData_
 Flag to save data. More...
 
std::atomic_bool isCopyingBuffer_
 Flag to save data. More...
 
std::atomic_bool isStarting_
 Flag is starting in different thread. More...
 
std::atomic_bool shouldPublish_
 Flag if data should be published. More...
 
boost::shared_mutex loggerMutex_
 Init, add, update, start, stop and cleanup should be called in sequence. More...
 
std::mutex saveLoggerDataMutex_
 Allow call to save logger data only once. More...
 

Constructor & Destructor Documentation

◆ SignalLoggerNone()

signal_logger::SignalLoggerNone::SignalLoggerNone ( )
inline

Constructor.

◆ ~SignalLoggerNone()

virtual signal_logger::SignalLoggerNone::~SignalLoggerNone ( )
inlinevirtual

Destructor.

Member Function Documentation

◆ add()

template<typename ValueType_ >
void signal_logger::SignalLoggerNone::add ( const ValueType_ *const  var,
const std::string &  name,
const std::string &  group = LOG_ELEMENT_DEFAULT_GROUP_NAME,
const std::string &  unit = LOG_ELEMENT_DEFAULT_UNIT,
const std::size_t  divider = LOG_ELEMENT_DEFAULT_DIVIDER,
const LogElementAction  action = LOG_ELEMENT_DEFAULT_ACTION,
const std::size_t  bufferSize = LOG_ELEMENT_DEFAULT_BUFFER_SIZE,
const BufferType  bufferType = LOG_ELEMENT_DEFAULT_BUFFER_TYPE 
)
inline

Add.

◆ collectLoggerData()

virtual bool signal_logger::SignalLoggerNone::collectLoggerData ( )
inlineoverridevirtual

Collect log data, read data and push it into the buffer.

Reimplemented from signal_logger::SignalLoggerBase.

◆ initLogger()

virtual void signal_logger::SignalLoggerNone::initLogger ( const SignalLoggerOptions options)
inlineoverridevirtual

Initializes the logger

Parameters
updateFrequencyUpdate frequency of the controller (frequency of collectLoggerData being called)
logScriptFileNameFilename of the log script, this specifies which topics shall be logged

Reimplemented from signal_logger::SignalLoggerBase.

◆ publishData()

virtual bool signal_logger::SignalLoggerNone::publishData ( )
inlineoverridevirtual

Publish a single data point of every element from the buffer.

Reimplemented from signal_logger::SignalLoggerBase.

◆ restartLogger()

virtual bool signal_logger::SignalLoggerNone::restartLogger ( bool  updateLogger = false)
inlineoverridevirtual

Stop and then restart the logger.

Reimplemented from signal_logger::SignalLoggerBase.

◆ saveLoggerData()

virtual bool signal_logger::SignalLoggerNone::saveLoggerData ( const signal_logger::LogFileTypeSet logfileTypes)
inlineoverridevirtual

Save all the buffered data into a log file.

Reimplemented from signal_logger::SignalLoggerBase.

◆ saveLoggerScript()

virtual bool signal_logger::SignalLoggerNone::saveLoggerScript ( const std::string &  scriptName = LOGGER_DEFAULT_SCRIPT_FILENAME)
inlineoverridevirtual

Save logger script.

Reimplemented from signal_logger::SignalLoggerBase.

◆ startLogger()

virtual bool signal_logger::SignalLoggerNone::startLogger ( bool  updateLogger = false)
inlineoverridevirtual

Starts the logger (enable collecting)

Reimplemented from signal_logger::SignalLoggerBase.

◆ stopAndSaveLoggerData()

virtual bool signal_logger::SignalLoggerNone::stopAndSaveLoggerData ( const signal_logger::LogFileTypeSet logfileTypes)
inlineoverridevirtual

Stop the logger and save all the buffered data into a log file.

Reimplemented from signal_logger::SignalLoggerBase.

◆ stopLogger()

virtual bool signal_logger::SignalLoggerNone::stopLogger ( )
inlineoverridevirtual

Stop the logger (disable collecting)

Reimplemented from signal_logger::SignalLoggerBase.

◆ updateLogger()

virtual bool signal_logger::SignalLoggerNone::updateLogger ( const bool  readScript = true,
const std::string &  scriptname = "" 
)
inlineoverridevirtual

Update the logger.

Reimplemented from signal_logger::SignalLoggerBase.

◆ workerSaveData()

virtual bool signal_logger::SignalLoggerNone::workerSaveData ( const std::string &  logFileName,
const signal_logger::LogFileTypeSet logfileTypes 
)
inlineoverrideprotectedvirtual

Saves the logger data in a file in a seperate thread.

Implements signal_logger::SignalLoggerBase.


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