ADORe
ADORe is a modular open source software library and toolkit for decision making, planning, control and simulation of automated vehicles
CSVLog Class Reference

singleton class for logging on the console and in a file, only interact with it via the defined macros More...

#include <csvlog.h>

Collaboration diagram for CSVLog:
Collaboration graph

Public Types

enum  LogLevel { _TRACE , _INFO , _WARNING , _ERROR }
 
enum  TimestampVersion { _TIMEOFDAY , _EPOCH }
 

Public Member Functions

 CSVLog ()
 Construct a new CSVLog object. More...
 
virtual ~CSVLog ()
 Destroy the CSVLog object. More...
 
void init (std::string filename)
 initialize log to file More...
 
void setLogLevel (LogLevel lvl)
 set the log level for file and console More...
 
void setLogLevelFromConsole ()
 set the log level via console input More...
 
void setLogLevelFile (LogLevel lvl)
 set log level only for file More...
 
void setLogLevelConsole (LogLevel lvl)
 set log level only for console More...
 
void setTimestampVersion (TimestampVersion tsv)
 set the time stamp version, time of day (0) or epoch (1) More...
 
void setSeperator (char seperator)
 set seperator for log in file More...
 
void setMaxLinesBuffer (int numLines)
 defines at how many lines in the buffer the buffer is written into a file More...
 
void setMaxLinesFile (int numLines)
 define after how many lines a new file is created More...
 
void setLowThroughputMode (bool b)
 in low throughput mode, the buffer is written to the file after a certain time even if the max buffer size is not reached yet More...
 
void setTimeBetweenWrites (double time_seconds)
 defines the max time between the buffer being written to the file in low throughput mode More...
 
void logTrace (const char *format,...)
 general log on trace level More...
 
void logTraceConsole (const char *format,...)
 log on trace level in console More...
 
void logTraceFile (const char *format,...)
 log on trace level in file More...
 
void logInfo (const char *format,...)
 general log on info level More...
 
void logInfoConsole (const char *format,...)
 log on info level in console More...
 
void logInfoFile (const char *format,...)
 log on info level in file More...
 
void logWarning (const char *format,...)
 general log on warning level More...
 
void logWarningConsole (const char *format,...)
 log on warning level in console More...
 
void logWarningFile (const char *format,...)
 log on warning level in file More...
 
void logError (const char *format,...)
 general log on error level More...
 
void logErrorConsole (const char *format,...)
 log on error level in console More...
 
void logErrorFile (const char *format,...)
 log on error level in file More...
 
bool hasFile ()
 check whether a file is available More...
 

Static Public Member Functions

static CSVLoggetInstance ()
 Get the singleton object of CSVLog. More...
 
static LogLevelgetCurrentLogLevelFile ()
 get current log level for file log More...
 
static LogLevelgetCurrentLogLevelConsole ()
 get current log level for console log More...
 

Private Member Functions

 CSVLog (const CSVLog &)
 
void operator= (CSVLog const &)
 
void writeLog (std::string msg, LogLevel lvl)
 general log generator method More...
 
void writeLogToConsole (std::string time, std::string msg, LogLevel lvl)
 general log generator for console More...
 
void writeLogToBuffer (std::string time, std::string msg, LogLevel lvl)
 general log generator for buffer More...
 
void writeBufferToFile ()
 writes content of buffer to file More...
 
void logConsole (std::string msg, LogLevel lvl)
 generate log entry in console More...
 
void logFile (std::string msg, LogLevel lvl)
 generate log entry in file More...
 
std::string getCurrentTime ()
 get time of day as string More...
 
std::string getCurrentTimeEpoch ()
 get epoch as string More...
 
std::string lvlToString (LogLevel lvl)
 get string for log level More...
 
int lvlToConsoleColor (LogLevel lvl)
 get console color from log level on windows More...
 
std::string lvlToConsoleColorLinux (LogLevel lvl)
 get console color from log level on linux More...
 

Private Attributes

char _seperator
 
int _linecountBuffer
 
int _linecountFile
 
int _maxLinesBuffer
 
int _maxLinesFile
 
double _maxTimeBetweenWrites
 
bool _useFile
 
bool _lowThroughputMode
 
TimestampVersion _timestampVersion
 
std::string _filename
 
std::string _currentFilename
 
std::ostringstream os
 
std::clock_t _lastWriteTime
 

Detailed Description

singleton class for logging on the console and in a file, only interact with it via the defined macros

Member Enumeration Documentation

◆ LogLevel

Enumerator
_TRACE 
_INFO 
_WARNING 
_ERROR 

◆ TimestampVersion

Enumerator
_TIMEOFDAY 
_EPOCH 

Constructor & Destructor Documentation

◆ CSVLog() [1/2]

CSVLog::CSVLog ( )

Construct a new CSVLog object.

◆ ~CSVLog()

CSVLog::~CSVLog ( )
virtual

Destroy the CSVLog object.

Here is the call graph for this function:

◆ CSVLog() [2/2]

CSVLog::CSVLog ( const CSVLog )
private

Member Function Documentation

◆ getCurrentLogLevelConsole()

CSVLog::LogLevel & CSVLog::getCurrentLogLevelConsole ( )
static

get current log level for console log

Returns
LogLevel&
Here is the caller graph for this function:

◆ getCurrentLogLevelFile()

CSVLog::LogLevel & CSVLog::getCurrentLogLevelFile ( )
static

get current log level for file log

Returns
LogLevel&
Here is the caller graph for this function:

◆ getCurrentTime()

std::string CSVLog::getCurrentTime ( )
private

get time of day as string

Returns
std::string
Here is the caller graph for this function:

◆ getCurrentTimeEpoch()

std::string CSVLog::getCurrentTimeEpoch ( )
private

get epoch as string

Returns
std::string
Here is the caller graph for this function:

◆ getInstance()

CSVLog & CSVLog::getInstance ( )
static

Get the singleton object of CSVLog.

Returns
CSVLog&

◆ hasFile()

bool CSVLog::hasFile ( )

check whether a file is available

Returns
true
false

◆ init()

void CSVLog::init ( std::string  filename)

initialize log to file

Parameters
filename

◆ logConsole()

void CSVLog::logConsole ( std::string  msg,
CSVLog::LogLevel  lvl 
)
private

generate log entry in console

Parameters
msg
lvl
Here is the call graph for this function:
Here is the caller graph for this function:

◆ logError()

void CSVLog::logError ( const char *  format,
  ... 
)

general log on error level

Parameters
format
...
Here is the call graph for this function:

◆ logErrorConsole()

void CSVLog::logErrorConsole ( const char *  format,
  ... 
)

log on error level in console

Parameters
format
...
Here is the call graph for this function:

◆ logErrorFile()

void CSVLog::logErrorFile ( const char *  format,
  ... 
)

log on error level in file

Parameters
format
...
Here is the call graph for this function:

◆ logFile()

void CSVLog::logFile ( std::string  msg,
CSVLog::LogLevel  lvl 
)
private

generate log entry in file

Parameters
msg
lvl
Here is the call graph for this function:
Here is the caller graph for this function:

◆ logInfo()

void CSVLog::logInfo ( const char *  format,
  ... 
)

general log on info level

Parameters
format
...
Here is the call graph for this function:

◆ logInfoConsole()

void CSVLog::logInfoConsole ( const char *  format,
  ... 
)

log on info level in console

Parameters
format
...
Here is the call graph for this function:

◆ logInfoFile()

void CSVLog::logInfoFile ( const char *  format,
  ... 
)

log on info level in file

Parameters
format
...
Here is the call graph for this function:

◆ logTrace()

void CSVLog::logTrace ( const char *  format,
  ... 
)

general log on trace level

Parameters
format
...
Here is the call graph for this function:

◆ logTraceConsole()

void CSVLog::logTraceConsole ( const char *  format,
  ... 
)

log on trace level in console

Parameters
format
...
Here is the call graph for this function:

◆ logTraceFile()

void CSVLog::logTraceFile ( const char *  format,
  ... 
)

log on trace level in file

Parameters
format
...
Here is the call graph for this function:

◆ logWarning()

void CSVLog::logWarning ( const char *  format,
  ... 
)

general log on warning level

Parameters
format
...
Here is the call graph for this function:

◆ logWarningConsole()

void CSVLog::logWarningConsole ( const char *  format,
  ... 
)

log on warning level in console

Parameters
format
...
Here is the call graph for this function:

◆ logWarningFile()

void CSVLog::logWarningFile ( const char *  format,
  ... 
)

log on warning level in file

Parameters
format
...
Here is the call graph for this function:

◆ lvlToConsoleColor()

int CSVLog::lvlToConsoleColor ( LogLevel  lvl)
private

get console color from log level on windows

Parameters
lvl
Returns
int

◆ lvlToConsoleColorLinux()

std::string CSVLog::lvlToConsoleColorLinux ( CSVLog::LogLevel  lvl)
private

get console color from log level on linux

Parameters
lvl
Returns
std::string
Here is the caller graph for this function:

◆ lvlToString()

std::string CSVLog::lvlToString ( CSVLog::LogLevel  lvl)
private

get string for log level

Parameters
lvl
Returns
std::string
Here is the caller graph for this function:

◆ operator=()

void CSVLog::operator= ( CSVLog const &  )
private

◆ setLogLevel()

void CSVLog::setLogLevel ( LogLevel  lvl)

set the log level for file and console

Parameters
lvl
Here is the call graph for this function:

◆ setLogLevelConsole()

void CSVLog::setLogLevelConsole ( LogLevel  lvl)

set log level only for console

Parameters
lvl
Here is the call graph for this function:

◆ setLogLevelFile()

void CSVLog::setLogLevelFile ( LogLevel  lvl)

set log level only for file

Parameters
lvl
Here is the call graph for this function:

◆ setLogLevelFromConsole()

void CSVLog::setLogLevelFromConsole ( )

set the log level via console input

◆ setLowThroughputMode()

void CSVLog::setLowThroughputMode ( bool  b)

in low throughput mode, the buffer is written to the file after a certain time even if the max buffer size is not reached yet

Parameters
b
Here is the caller graph for this function:

◆ setMaxLinesBuffer()

void CSVLog::setMaxLinesBuffer ( int  numLines)

defines at how many lines in the buffer the buffer is written into a file

Parameters
numLines

◆ setMaxLinesFile()

void CSVLog::setMaxLinesFile ( int  numLines)

define after how many lines a new file is created

Parameters
numLines

◆ setSeperator()

void CSVLog::setSeperator ( char  seperator)

set seperator for log in file

Parameters
seperator

◆ setTimeBetweenWrites()

void CSVLog::setTimeBetweenWrites ( double  time_seconds)

defines the max time between the buffer being written to the file in low throughput mode

Parameters
time_seconds
Here is the call graph for this function:

◆ setTimestampVersion()

void CSVLog::setTimestampVersion ( CSVLog::TimestampVersion  tsv)

set the time stamp version, time of day (0) or epoch (1)

Parameters
tsv

◆ writeBufferToFile()

void CSVLog::writeBufferToFile ( )
private

writes content of buffer to file

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeLog()

void CSVLog::writeLog ( std::string  msg,
CSVLog::LogLevel  lvl 
)
private

general log generator method

Parameters
msg
lvl
Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeLogToBuffer()

void CSVLog::writeLogToBuffer ( std::string  time,
std::string  msg,
CSVLog::LogLevel  lvl 
)
private

general log generator for buffer

Parameters
time
msg
lvl
Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeLogToConsole()

void CSVLog::writeLogToConsole ( std::string  time,
std::string  msg,
CSVLog::LogLevel  lvl 
)
private

general log generator for console

Parameters
time
msg
lvl
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ _currentFilename

std::string CSVLog::_currentFilename
private

◆ _filename

std::string CSVLog::_filename
private

◆ _lastWriteTime

std::clock_t CSVLog::_lastWriteTime
private

◆ _linecountBuffer

int CSVLog::_linecountBuffer
private

◆ _linecountFile

int CSVLog::_linecountFile
private

◆ _lowThroughputMode

bool CSVLog::_lowThroughputMode
private

◆ _maxLinesBuffer

int CSVLog::_maxLinesBuffer
private

◆ _maxLinesFile

int CSVLog::_maxLinesFile
private

◆ _maxTimeBetweenWrites

double CSVLog::_maxTimeBetweenWrites
private

◆ _seperator

char CSVLog::_seperator
private

◆ _timestampVersion

TimestampVersion CSVLog::_timestampVersion
private

◆ _useFile

bool CSVLog::_useFile
private

◆ os

std::ostringstream CSVLog::os
private

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