DynuIPRefresher/src/Logger.cpp

47 lines
958 B
C++
Raw Normal View History

#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) {
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) {
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) {
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) {
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 << "[";
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;
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