2020-05-05 17:25:23 +00:00
|
|
|
#include "Logger.h"
|
|
|
|
|
2019-05-05 14:35:38 +00:00
|
|
|
#include <sstream>
|
2019-10-26 12:41:43 +00:00
|
|
|
#include <iostream>
|
2019-05-05 14:35:38 +00:00
|
|
|
|
2020-04-30 10:16:29 +00:00
|
|
|
void Logger::debug(const std::string message) {
|
2019-10-27 12:41:40 +00:00
|
|
|
log(message, Logger::Debug);
|
2019-05-05 14:35:38 +00:00
|
|
|
}
|
|
|
|
|
2020-04-30 10:16:29 +00:00
|
|
|
void Logger::message(const std::string message) {
|
2019-10-27 12:41:40 +00:00
|
|
|
log(message, Logger::Message);
|
2019-10-26 12:41:43 +00:00
|
|
|
}
|
2019-05-05 14:35:38 +00:00
|
|
|
|
2020-04-30 10:16:29 +00:00
|
|
|
void Logger::warning(const std::string message) {
|
2019-10-27 12:41:40 +00:00
|
|
|
log(message, Logger::Warning);
|
2019-10-26 12:41:43 +00:00
|
|
|
}
|
2019-05-05 14:35:38 +00:00
|
|
|
|
2020-04-30 10:16:29 +00:00
|
|
|
void Logger::error(const std::string message) {
|
2019-10-27 12:41:40 +00:00
|
|
|
log(message, Logger::Error);
|
2019-10-26 12:41:43 +00:00
|
|
|
}
|
2019-05-05 14:35:38 +00:00
|
|
|
|
2020-04-30 10:16:29 +00:00
|
|
|
void Logger::log(const std::string &message, int level) {
|
2019-10-26 12:41:43 +00:00
|
|
|
std::stringstream out;
|
|
|
|
out << "[";
|
2019-10-27 12:41:40 +00:00
|
|
|
switch (level) {
|
2019-10-26 12:41:43 +00:00
|
|
|
case Debug:
|
|
|
|
out << "DEBUG";
|
|
|
|
break;
|
|
|
|
case Message:
|
|
|
|
out << "MESSAGE";
|
|
|
|
break;
|
|
|
|
case Warning:
|
|
|
|
out << "WARNING";
|
|
|
|
break;
|
|
|
|
case Error:
|
|
|
|
out << "ERROR";
|
|
|
|
break;
|
2020-05-01 13:33:20 +00:00
|
|
|
default:
|
|
|
|
out << "UNDEFINED";
|
|
|
|
break;
|
2019-10-26 12:41:43 +00:00
|
|
|
}
|
|
|
|
out << "] ";
|
|
|
|
out << message;
|
|
|
|
std::cout << out.str() << std::endl;
|
2019-05-05 14:35:38 +00:00
|
|
|
}
|
2019-10-26 12:41:43 +00:00
|
|
|
|