Inject logger instead of using a singleton

This commit is contained in:
2019-06-16 11:33:23 +02:00
parent 14740e4a64
commit 9ba225cbde
14 changed files with 76 additions and 56 deletions

View File

@@ -1,32 +1,35 @@
#include <cstdio>
#include "logger.hpp"
void Log(std::string const & label, std::string const & message)
{
std::printf("[%s] %s\n", label.c_str(), message.c_str());
}
void Logger::Success(const std::string & s)
{
Log("SUCCESS", s);
}
void Logger::Error(const std::string & s)
{
Log("ERROR", s);
}
void Logger::Info(const std::string & s)
{
Log("INFO", s);
}
void Logger::Debug(const std::string & s)
{
Log("DEBUG", s);
}
Logger::~Logger()
{
}
Logger::Logger()
{
}
void Logger::Success(const std::string & s)
{
std::printf("[SUCCESS] %s\n", s.c_str());
}
void Logger::Error(const std::string & s)
{
std::printf("[ERROR] %s\n", s.c_str());
}
void Logger::Info(const std::string & s)
{
std::printf("[INFO] %s\n", s.c_str());
}
Logger & Logger::GetInstance()
{
static Logger logger;
return logger;
}