tsLogger
A C++17 data logger for timeseries and snapshot data
Loading...
Searching...
No Matches
tsLogger Class Reference

The core class of the library is the tsLogger class. Multiple simultaneous class objects are supported. More...

#include <include/tsLogger.h>

Public Member Functions

 tsLogger ()
 Default constructor of the tsLogger class. Uses default values to initialize all object properties.
 
 tsLogger (tsLogFileType logFileType)
 An overloaded 1-parameter constructor of the tsLogger class. Allows the user to set the logfile type.
 
 tsLogger (const char *logFileName)
 An overloaded 1-parameter constructor of the tsLogger class. Allows the user to set the logfile name.
 
 tsLogger (const char *logFileName, tsLogFileType logFileType)
 An overloaded 2-parameter constructor of the tsLogger class. Allows the user to set the file type and file name.
 
 tsLogger (const char *logFileName, tsLogFileType logFileType, size_t logBufferMaxSize)
 An overloaded 3-parameter constructor of the tsLogger class. Allows the user to select file type, file name and internal log buffer size.
 
void getFilePath (char *pathDestination, size_t pathDestinationLength)
 Allows the user to read the file path of the log file.
 
size_t getNumDataPoints ()
 Returns the total number of data points being tracked for logging by the tsLogger class object.
 
template<typename T >
unsigned trackDataPoint (T *dataPointer, const std::string &dataName)
 Template member function that appends the data point to the list of tracked data.
 
void appendToPreamble (std::string appendString)
 Appends a line of text to the preamble block of the log file. Replaces new line characters with spaces.
 
void addPreamble ()
 Adds the preamble to the log file-can only be added once and only be called before the addDataHeader function.
 
void addDataHeader ()
 Add the data header (consisting of datapoint names separated by commas) to the header file. Do not call trackDataPoint after this function call.
 
void startLogger ()
 Starts the logger and locks out the ability to add preambles, headers and new data points.
 
void logData ()
 Logs the data points being tracked as a line in the log file.
 
 ~tsLogger ()
 

Detailed Description

The core class of the library is the tsLogger class. Multiple simultaneous class objects are supported.

Definition at line 50 of file tsLogger.h.

Constructor & Destructor Documentation

◆ tsLogger() [1/5]

tsLogger::tsLogger ( )

Default constructor of the tsLogger class. Uses default values to initialize all object properties.

Definition at line 41 of file tsLogger.cpp.

◆ tsLogger() [2/5]

tsLogger::tsLogger ( tsLogFileType  logFileType)

An overloaded 1-parameter constructor of the tsLogger class. Allows the user to set the logfile type.

Parameters
logFileTypeThe file type of the logfile per the tsLogFileType enum.

Definition at line 62 of file tsLogger.cpp.

◆ tsLogger() [3/5]

tsLogger::tsLogger ( const char *  logFileName)

An overloaded 1-parameter constructor of the tsLogger class. Allows the user to set the logfile name.

Parameters
logFileNameThe file name of the logfile. You can optionally provide the full file path if you want the file to reside in a particular location.

Definition at line 83 of file tsLogger.cpp.

◆ tsLogger() [4/5]

tsLogger::tsLogger ( const char *  logFileName,
tsLogFileType  logFileType 
)

An overloaded 2-parameter constructor of the tsLogger class. Allows the user to set the file type and file name.

Parameters
logFileNameThe file name of the logfile. You can optionally provide the full file path if you want the file to reside in a particular location.
logFileTypeThe file type of the logfile per the tsLogFileType enum.

Definition at line 93 of file tsLogger.cpp.

◆ tsLogger() [5/5]

tsLogger::tsLogger ( const char *  logFileName,
tsLogFileType  logFileType,
size_t  logBufferMaxSize 
)

An overloaded 3-parameter constructor of the tsLogger class. Allows the user to select file type, file name and internal log buffer size.

Parameters
logFileNameThe file name of the logfile. You can optionally provide the full file path if you want the file to reside in a particular location.
logFileTypeThe file type of the logfile per the tsLogFileType enum.
logBufferMaxSizeThe buffer size of the internal log buffer. When the buffer is full, the data is dumped to file.

Definition at line 103 of file tsLogger.cpp.

◆ ~tsLogger()

tsLogger::~tsLogger ( )

Definition at line 236 of file tsLogger.cpp.

Member Function Documentation

◆ addDataHeader()

void tsLogger::addDataHeader ( )

Add the data header (consisting of datapoint names separated by commas) to the header file. Do not call trackDataPoint after this function call.

Definition at line 142 of file tsLogger.cpp.

◆ addPreamble()

void tsLogger::addPreamble ( )

Adds the preamble to the log file-can only be added once and only be called before the addDataHeader function.

Definition at line 131 of file tsLogger.cpp.

◆ appendToPreamble()

void tsLogger::appendToPreamble ( std::string  appendString)

Appends a line of text to the preamble block of the log file. Replaces new line characters with spaces.

Parameters
appendStringString to append.

Definition at line 123 of file tsLogger.cpp.

◆ getFilePath()

void tsLogger::getFilePath ( char *  pathDestination,
size_t  pathDestinationLength 
)

Allows the user to read the file path of the log file.

Parameters
pathDestinationThe pointer to the character array to which the user wants the file path to be written.
pathDestinationLengthThe maximum length of data allowed to be written to the character array.

Definition at line 113 of file tsLogger.cpp.

◆ getNumDataPoints()

size_t tsLogger::getNumDataPoints ( )

Returns the total number of data points being tracked for logging by the tsLogger class object.

Returns
The number of data points being tracked by the logger object.

Definition at line 118 of file tsLogger.cpp.

◆ logData()

void tsLogger::logData ( )

Logs the data points being tracked as a line in the log file.

Definition at line 173 of file tsLogger.cpp.

◆ startLogger()

void tsLogger::startLogger ( )

Starts the logger and locks out the ability to add preambles, headers and new data points.

Definition at line 166 of file tsLogger.cpp.

◆ trackDataPoint()

template<typename T >
unsigned tsLogger::trackDataPoint ( T *  dataPointer,
const std::string &  dataName 
)
inline

Template member function that appends the data point to the list of tracked data.

Template Parameters
TTemplate data type of the data point that needs to be tracked. Support data types are governed by smartDataPtr.
Parameters
dataPointerPointer/reference to the data point that needs to be tracked.
dataNameName of the data point that needs to be tracked. This name is used to build the header line of the log file.
Returns
The total number of data points being tracked including the new data point if successful and a negative number if there was an error.

Definition at line 143 of file tsLogger.h.


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