Files
mcpe/source/common/Logger.cpp
2023-08-28 11:01:12 +03:00

50 lines
792 B
C++

#include <iostream>
#include <stdarg.h>
#include "Logger.hpp"
#include "Util.hpp"
Logger* Logger::m_singleton = nullptr;
Logger* const Logger::singleton()
{
return m_singleton;
}
Logger::Logger()
{
// Stick with the first output handle we get
if (!m_singleton)
m_singleton = this;
}
Logger::~Logger()
{
if (m_singleton == this)
m_singleton = nullptr;
}
void Logger::print(const char* const str)
{
std::cout << str << std::endl;
}
void Logger::print(std::string str)
{
print(str.c_str());
}
void Logger::vprintf(const char* const fmt, va_list argPtr)
{
print(Util::vformat(fmt, argPtr));
}
void Logger::printf(const char* const fmt, ...)
{
va_list argList;
va_start(argList, fmt);
vprintf(fmt, argList);
va_end(argList);
}