Add stderr output =))
This commit is contained in:
@@ -48,6 +48,7 @@ class LoggerClass {
|
||||
char str[20];
|
||||
strftime(str, sizeof(str), "%T", now);
|
||||
std::string logLevelStr;
|
||||
|
||||
switch (logLevel) {
|
||||
case DEBUG: logLevelStr = std::string("DEBUG"); break;
|
||||
case INFO: logLevelStr = std::string("INFO"); break;
|
||||
@@ -57,13 +58,21 @@ class LoggerClass {
|
||||
default: logLevelStr = std::string("UNKNOWN"); break;
|
||||
};
|
||||
line = std::string(str) + " - [" + logLevelStr + "] " + message + "\n";
|
||||
if (logLevel > 2) {
|
||||
print(line);
|
||||
}
|
||||
else {
|
||||
printErr(line);
|
||||
}
|
||||
addToFile(line);
|
||||
}
|
||||
|
||||
void print(const std::string& message) {
|
||||
std::cout << message;
|
||||
}
|
||||
void printErr(const std::string& message) {
|
||||
std::cerr << message;
|
||||
}
|
||||
|
||||
void addToFile(const std::string& message) {
|
||||
if (!openLogFileFailed) {
|
||||
|
||||
Reference in New Issue
Block a user