28 #define LOG_T(...) if (CSVLog::getCurrentLogLevelConsole()<=CSVLog::_TRACE) \
29 CSVLog::getInstance().logTraceConsole(__VA_ARGS__); \
30 if (CSVLog::getInstance().hasFile() && CSVLog::getCurrentLogLevelFile()<=CSVLog::_TRACE) \
31 CSVLog::getInstance().logTraceFile(__VA_ARGS__)
37 #define LOG_I(...) if (CSVLog::getCurrentLogLevelConsole()<=CSVLog::_INFO) \
38 CSVLog::getInstance().logInfoConsole(__VA_ARGS__); \
39 if (CSVLog::getInstance().hasFile() && CSVLog::getCurrentLogLevelFile()<=CSVLog::_INFO) \
40 CSVLog::getInstance().logInfoFile(__VA_ARGS__)
46 #define LOG_W(...) if (CSVLog::getCurrentLogLevelConsole()<=CSVLog::_WARNING) \
47 CSVLog::getInstance().logWarningConsole(__VA_ARGS__); \
48 if (CSVLog::getInstance().hasFile() && CSVLog::getCurrentLogLevelFile()<=CSVLog::_WARNING) \
49 CSVLog::getInstance().logWarningFile(__VA_ARGS__)
55 #define LOG_E(...) if (CSVLog::getCurrentLogLevelConsole()<=CSVLog::_ERROR) \
56 CSVLog::getInstance().logErrorConsole(__VA_ARGS__); \
57 if (CSVLog::getInstance().hasFile() && CSVLog::getCurrentLogLevelFile()<=CSVLog::_ERROR) \
58 CSVLog::getInstance().logErrorFile(__VA_ARGS__)
64 #define LOG_SET_LVL_FROM_CONSOLE(...) CSVLog::getInstance().setLogLevelFromConsole()
70 #define LOG_SET_LVL_T(...) CSVLog::getInstance().setLogLevel(CSVLog::_TRACE)
76 #define LOG_SET_LVL_I(...) CSVLog::getInstance().setLogLevel(CSVLog::_INFO)
82 #define LOG_SET_LVL_W(...) CSVLog::getInstance().setLogLevel(CSVLog::_WARNING)
88 #define LOG_SET_LVL_E(...) CSVLog::getInstance().setLogLevel(CSVLog::_ERROR)
94 #define LOG_SET_LVL_CONSOLE_T(...) CSVLog::getInstance().setLogLevelConsole(CSVLog::_TRACE)
100 #define LOG_SET_LVL_CONSOLE_I(...) CSVLog::getInstance().setLogLevelConsole(CSVLog::_INFO)
106 #define LOG_SET_LVL_CONSOLE_W(...) CSVLog::getInstance().setLogLevelConsole(CSVLog::_WARNING)
112 #define LOG_SET_LVL_CONSOLE_E(...) CSVLog::getInstance().setLogLevelConsole(CSVLog::_ERROR)
118 #define LOG_SET_LVL_FILE_T(...) CSVLog::getInstance().setLogLevelFile(CSVLog::_TRACE)
124 #define LOG_SET_LVL_FILE_I(...) CSVLog::getInstance().setLogLevelFile(CSVLog::_INFO)
130 #define LOG_SET_LVL_FILE_W(...) CSVLog::getInstance().setLogLevelFile(CSVLog::_WARNING)
136 #define LOG_SET_LVL_FILE_E(...) CSVLog::getInstance().setLogLevelFile(CSVLog::_ERROR)
143 #define LOG_SET_SEPERATOR(char_seperator) CSVLog::getInstance().setSeperator(char_seperator)
149 #define LOG_SET_MAXLINES_FILE(int_maxLines) CSVLog::getInstance().setMaxLinesFile(int_maxLines)
155 #define LOG_SET_MAXLINES_BUFFER(int_maxLines) CSVLog::getInstance().setMaxLinesBuffer(int_maxLines)
161 #define LOG_SET_TIMESTAMPVERSION(timestampversion_tsv) CSVLog::getInstance().setTimestampVersion(timestampversion_tsv)
167 #define LOG_SET_LOWTHROUGHPUTMODE(bool_active) CSVLog::getInstance().setLowThroughputMode(bool_active)
173 #define LOG_SET_MAXTIMEBETWEENWRITES(double_time_seconds) CSVLog::getInstance().setTimeBetweenWrites(double_time_seconds)
179 #define LOG_INIT(string_filename) CSVLog::getInstance().init(string_filename)
224 void init(std::string filename);
315 void logTrace(
const char *format, ...);
339 void logInfo(
const char *format, ...);
387 void logError(
const char *format, ...);
428 std::ostringstream
os;
singleton class for logging on the console and in a file, only interact with it via the defined macro...
Definition: csvlog.h:186
void setLogLevelFromConsole()
set the log level via console input
Definition: csvlog.cpp:285
void logErrorConsole(const char *format,...)
log on error level in console
Definition: csvlog.cpp:155
void logInfoFile(const char *format,...)
log on info level in file
Definition: csvlog.cpp:128
std::clock_t _lastWriteTime
Definition: csvlog.h:430
std::string _filename
Definition: csvlog.h:426
LogLevel
Definition: csvlog.h:207
@ _TRACE
Definition: csvlog.h:208
@ _WARNING
Definition: csvlog.h:210
@ _INFO
Definition: csvlog.h:209
@ _ERROR
Definition: csvlog.h:211
std::string lvlToConsoleColorLinux(LogLevel lvl)
get console color from log level on linux
Definition: csvlog.cpp:401
double _maxTimeBetweenWrites
Definition: csvlog.h:422
void logConsole(std::string msg, LogLevel lvl)
generate log entry in console
Definition: csvlog.cpp:227
void logWarning(const char *format,...)
general log on warning level
Definition: csvlog.cpp:134
TimestampVersion
Definition: csvlog.h:214
@ _TIMEOFDAY
Definition: csvlog.h:215
@ _EPOCH
Definition: csvlog.h:216
TimestampVersion _timestampVersion
Definition: csvlog.h:425
void setLogLevelConsole(LogLevel lvl)
set log level only for console
Definition: csvlog.cpp:44
void logTraceFile(const char *format,...)
log on trace level in file
Definition: csvlog.cpp:112
void logWarningConsole(const char *format,...)
log on warning level in console
Definition: csvlog.cpp:139
int _linecountBuffer
Definition: csvlog.h:418
void operator=(CSVLog const &)
void writeBufferToFile()
writes content of buffer to file
Definition: csvlog.cpp:263
void writeLogToBuffer(std::string time, std::string msg, LogLevel lvl)
general log generator for buffer
Definition: csvlog.cpp:279
void logTrace(const char *format,...)
general log on trace level
Definition: csvlog.cpp:102
static LogLevel & getCurrentLogLevelConsole()
get current log level for console log
Definition: csvlog.cpp:89
void writeLog(std::string msg, LogLevel lvl)
general log generator method
Definition: csvlog.cpp:207
void logInfo(const char *format,...)
general log on info level
Definition: csvlog.cpp:118
virtual ~CSVLog()
Destroy the CSVLog object.
Definition: csvlog.cpp:184
std::string getCurrentTime()
get time of day as string
Definition: csvlog.cpp:373
void setTimeBetweenWrites(double time_seconds)
defines the max time between the buffer being written to the file in low throughput mode
Definition: csvlog.cpp:74
void setLogLevel(LogLevel lvl)
set the log level for file and console
Definition: csvlog.cpp:33
void setMaxLinesFile(int numLines)
define after how many lines a new file is created
Definition: csvlog.cpp:54
int _maxLinesBuffer
Definition: csvlog.h:420
static CSVLog & getInstance()
Get the singleton object of CSVLog.
Definition: csvlog.cpp:25
void logError(const char *format,...)
general log on error level
Definition: csvlog.cpp:150
void setSeperator(char seperator)
set seperator for log in file
Definition: csvlog.cpp:64
std::string _currentFilename
Definition: csvlog.h:427
void setLowThroughputMode(bool b)
in low throughput mode, the buffer is written to the file after a certain time even if the max buffer...
Definition: csvlog.cpp:69
int _linecountFile
Definition: csvlog.h:419
std::ostringstream os
Definition: csvlog.h:428
int lvlToConsoleColor(LogLevel lvl)
get console color from log level on windows
std::string lvlToString(LogLevel lvl)
get string for log level
Definition: csvlog.cpp:318
bool hasFile()
check whether a file is available
Definition: csvlog.cpp:95
void writeLogToConsole(std::string time, std::string msg, LogLevel lvl)
general log generator for console
Definition: csvlog.cpp:396
void logTraceConsole(const char *format,...)
log on trace level in console
Definition: csvlog.cpp:107
void setLogLevelFile(LogLevel lvl)
set log level only for file
Definition: csvlog.cpp:39
bool _lowThroughputMode
Definition: csvlog.h:424
void logFile(std::string msg, LogLevel lvl)
generate log entry in file
Definition: csvlog.cpp:240
static LogLevel & getCurrentLogLevelFile()
get current log level for file log
Definition: csvlog.cpp:83
void init(std::string filename)
initialize log to file
Definition: csvlog.cpp:190
std::string getCurrentTimeEpoch()
get epoch as string
Definition: csvlog.cpp:387
char _seperator
Definition: csvlog.h:417
void logInfoConsole(const char *format,...)
log on info level in console
Definition: csvlog.cpp:123
void logErrorFile(const char *format,...)
log on error level in file
Definition: csvlog.cpp:160
void setTimestampVersion(TimestampVersion tsv)
set the time stamp version, time of day (0) or epoch (1)
Definition: csvlog.cpp:49
void logWarningFile(const char *format,...)
log on warning level in file
Definition: csvlog.cpp:144
bool _useFile
Definition: csvlog.h:423
CSVLog()
Construct a new CSVLog object.
Definition: csvlog.cpp:168
int _maxLinesFile
Definition: csvlog.h:421
void setMaxLinesBuffer(int numLines)
defines at how many lines in the buffer the buffer is written into a file
Definition: csvlog.cpp:59