WarpTwin
Documentation for WarpTwin models and classes.
Loading...
Searching...
No Matches
warptwin::CsvLogger Class Reference

Class for logging to CSV. More...

#include <CsvLogger.h>

Inherits clockwerk::SimLogger.

Public Member Functions

 CsvLogger (warpos::FlightExecutive &exec, const std::string &filename="output.csv", unsigned int buffer_size=1000)
 Constructor for CSV logger – wraps around logger constructor.
 ~CsvLogger ()
int delimeter (const std::string &delim)
 Function to set the delimeter.
int filename (std::string name)
 Function to set CSV logger filename.
int close ()
 Function to close down the file – logs remaining buffered data and closes.
int setPrecision (int precision)
 Function to set the precision of CSV logging.
log_level_e logLevel ()
 Get the log level set for the executive.
void logLevel (log_level_e log_level)
 Set the executive log level.

Protected Member Functions

int _createSetupFile ()
 Function to create a CSV file for logging.
int _writeToFile ()
 Function to write buffered data to CSV file.

Protected Attributes

std::ofstream _fout
 Stream variable to write file to.
std::string _delimeter
 String to indicate delimeter – set to comma by default.
warpos::FlightExecutiveexc
 Handle to executive for logging.
int _precision = 20
 The precision of logging. Default is 20 places.
log_level_e _local_log_level = log_level_e::LOG_WARNING
 The log level for this particular app.

Detailed Description

Class for logging to CSV.

The CSV logger is a class that inherits from the base logger class and manually configures it to write to CSV.

Constructor & Destructor Documentation

◆ CsvLogger()

warptwin::CsvLogger::CsvLogger ( warpos::FlightExecutive & exec,
const std::string & filename = "output.csv",
unsigned int buffer_size = 1000 )

Constructor for CSV logger – wraps around logger constructor.

◆ ~CsvLogger()

warptwin::CsvLogger::~CsvLogger ( )
inline

Member Function Documentation

◆ _createSetupFile()

int warptwin::CsvLogger::_createSetupFile ( )
protected

Function to create a CSV file for logging.

◆ _writeToFile()

int warptwin::CsvLogger::_writeToFile ( )
protected

Function to write buffered data to CSV file.

◆ close()

int warptwin::CsvLogger::close ( )

Function to close down the file – logs remaining buffered data and closes.

◆ delimeter()

int warptwin::CsvLogger::delimeter ( const std::string & delim)

Function to set the delimeter.

Parameters
delimThe delimeter to separate file values

◆ filename()

int warptwin::CsvLogger::filename ( std::string name)

Function to set CSV logger filename.

Parameters
Thefilename to set. If no extension applies, auto-set to .csv
Returns
Error code corresponding to success/failure

◆ logLevel() [1/2]

log_level_e warptwin::CsvLogger::logLevel ( )
inline

Get the log level set for the executive.

Returns
Log level for the executive

◆ logLevel() [2/2]

void warptwin::CsvLogger::logLevel ( log_level_e log_level)
inline

Set the executive log level.

Parameters
log_levelThe level to set logging to

◆ setPrecision()

int warptwin::CsvLogger::setPrecision ( int precision)

Function to set the precision of CSV logging.

Parameters
precisionThe precision to set logging to as # of decimal places
Returns
Error code corresponding to success/failure

Member Data Documentation

◆ _delimeter

std::string warptwin::CsvLogger::_delimeter
protected

String to indicate delimeter – set to comma by default.

◆ _fout

std::ofstream warptwin::CsvLogger::_fout
protected

Stream variable to write file to.

◆ _local_log_level

log_level_e warptwin::CsvLogger::_local_log_level = log_level_e::LOG_WARNING
protected

The log level for this particular app.

◆ _precision

int warptwin::CsvLogger::_precision = 20
protected

The precision of logging. Default is 20 places.

◆ exc

warpos::FlightExecutive& warptwin::CsvLogger::exc
protected

Handle to executive for logging.


The documentation for this class was generated from the following files:
  • /Users/mickey/Documents/Projects/warptwin/cpp/src/logging/CsvLogger.h
  • /Users/mickey/Documents/Projects/warptwin/cpp/src/logging/CsvLogger.cpp