Inject logger instead of using a singleton
This commit is contained in:
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user