This commit is contained in:
Sven Luethi committed 2021-03-26 22:35:27 +01:00
1 parent f25a834fbd
commit 062f9c8c69
6 files changed
+99 -34

No files matched your search

+19 -7
View File
@@ -72,20 +72,32 @@ void Logger::Sink::ln ( const char* msg ) {
if(_lineIsPrefixed) *_parent._output << endl;
prefixLine(true);
*_parent._output << msg << endl;
cout << msg << CC_RESET "\n";
}
}
void Logger::Sink::prefixLine(bool resetToFalse) {
if (!_lineIsPrefixed) {
const char* lvlString;
const string timestamp = Logger::genTimeStamp();
switch ( _level)
{
case DEBUG: lvlString = "DEBUG"; break;
case INFO: lvlString = "INFO "; break;
case WARN: lvlString = "WARN "; break;
case FATAL: lvlString = "FATAL"; break;
case DEBUG:
*_parent._output << timestamp << " " << "DEBUG ";
cout << timestamp << " " << CC_BLUE "DEBUG ";
break;
case INFO:
*_parent._output << timestamp << " " << "INFO ";
cout << timestamp << " " << CC_GREEN "INFO ";
break;
case WARN:
*_parent._output << timestamp << " " << "WARN ";
cout << timestamp << " " << CC_YELLOW "WARN ";
break;
case FATAL:
*_parent._output << timestamp << " " << "FATAL ";
cout << timestamp << " " << CC_RED "FATAL ";
break;
}
*_parent._output << Logger::genTimeStamp() << " " << lvlString << " ";
_lineIsPrefixed = resetToFalse ? false : true;
}
}
@@ -106,7 +118,6 @@ Logger::Sink& Logger::Sink::operator<<(const char* msg) {
return *this;
}
Logger::Sink& Logger::Sink::operator<<(const int msg) {
if ( _level >= _parent._logLevel ) {
prefixLine();
@@ -137,6 +148,7 @@ Logger::Sink& Logger::Sink::operator<<(const char character) {
// COMMIT - End message line
case 0:
*_parent._output << endl;
cout << CC_RESET "\n";
_lineIsPrefixed = false;
break;
}