singleton class for logging on the console and in a file, only interact with it via the defined macros More...
#include <csvlog.h>
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 CSVLog & | getInstance () |
Get the singleton object of CSVLog. More... | |
static LogLevel & | getCurrentLogLevelFile () |
get current log level for file log More... | |
static LogLevel & | getCurrentLogLevelConsole () |
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 |
singleton class for logging on the console and in a file, only interact with it via the defined macros
enum CSVLog::LogLevel |
CSVLog::CSVLog | ( | ) |
Construct a new CSVLog object.
|
virtual |
|
private |
|
static |
get current log level for console log
|
static |
get current log level for file log
|
private |
get time of day as string
|
private |
get epoch as string
bool CSVLog::hasFile | ( | ) |
check whether a file is available
void CSVLog::init | ( | std::string | filename | ) |
initialize log to file
filename |
|
private |
generate log entry in console
msg | |
lvl |
void CSVLog::logError | ( | const char * | format, |
... | |||
) |
general log on error level
format | |
... |
void CSVLog::logErrorConsole | ( | const char * | format, |
... | |||
) |
log on error level in console
format | |
... |
void CSVLog::logErrorFile | ( | const char * | format, |
... | |||
) |
log on error level in file
format | |
... |
|
private |
generate log entry in file
msg | |
lvl |
void CSVLog::logInfo | ( | const char * | format, |
... | |||
) |
general log on info level
format | |
... |
void CSVLog::logInfoConsole | ( | const char * | format, |
... | |||
) |
log on info level in console
format | |
... |
void CSVLog::logInfoFile | ( | const char * | format, |
... | |||
) |
log on info level in file
format | |
... |
void CSVLog::logTrace | ( | const char * | format, |
... | |||
) |
general log on trace level
format | |
... |
void CSVLog::logTraceConsole | ( | const char * | format, |
... | |||
) |
log on trace level in console
format | |
... |
void CSVLog::logTraceFile | ( | const char * | format, |
... | |||
) |
log on trace level in file
format | |
... |
void CSVLog::logWarning | ( | const char * | format, |
... | |||
) |
general log on warning level
format | |
... |
void CSVLog::logWarningConsole | ( | const char * | format, |
... | |||
) |
log on warning level in console
format | |
... |
void CSVLog::logWarningFile | ( | const char * | format, |
... | |||
) |
log on warning level in file
format | |
... |
|
private |
get console color from log level on windows
lvl |
|
private |
get console color from log level on linux
lvl |
|
private |
get string for log level
lvl |
|
private |
void CSVLog::setLogLevel | ( | LogLevel | lvl | ) |
set the log level for file and console
lvl |
void CSVLog::setLogLevelConsole | ( | LogLevel | lvl | ) |
set log level only for console
lvl |
void CSVLog::setLogLevelFile | ( | LogLevel | lvl | ) |
set log level only for file
lvl |
void CSVLog::setLogLevelFromConsole | ( | ) |
set the log level via console input
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
b |
void CSVLog::setMaxLinesBuffer | ( | int | numLines | ) |
defines at how many lines in the buffer the buffer is written into a file
numLines |
void CSVLog::setMaxLinesFile | ( | int | numLines | ) |
define after how many lines a new file is created
numLines |
void CSVLog::setSeperator | ( | char | seperator | ) |
set seperator for log in file
seperator |
void CSVLog::setTimeBetweenWrites | ( | double | time_seconds | ) |
defines the max time between the buffer being written to the file in low throughput mode
time_seconds |
void CSVLog::setTimestampVersion | ( | CSVLog::TimestampVersion | tsv | ) |
set the time stamp version, time of day (0) or epoch (1)
tsv |
|
private |
writes content of buffer to file
|
private |
general log generator method
msg | |
lvl |
|
private |
general log generator for buffer
time | |
msg | |
lvl |
|
private |
general log generator for console
time | |
msg | |
lvl |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |