ProtoTank/Engine/Misc/Logger.hpp

36 lines
999 B
C++

#pragma once
#include <fstream>
#include "../Utils/Timers.hpp"
//TODO: Should be upgraded using FMT lib
class Logger final {
public:
static Logger& getInstance() {
if (smInstance == nullptr)
smInstance = new Logger();
return *smInstance;
}
~Logger() = default;
Logger(Logger&&) = default;
Logger& operator= (Logger&&) = default;
Logger(Logger const&) = delete;
Logger& operator= (Logger const&) = delete;
void PrintInfo(std::string inPrt, bool writeToFile = false);
void PrintWarning(std::string inPrt, bool writeToFile = false);
void PrintCritical(std::string inPrt, bool writeToFile = false);
void PrintDebug(std::string inPrt, bool writeToFile = false);
private:
Logger() noexcept(false);
static Logger* smInstance;
std::unique_ptr<SysTimer> mLogTimer = nullptr;
};
#define LOGGER_MSG_FT(x) std::string(__FUNCTION__) + std::string("@") + std::to_string(__LINE__) + std::string(": ") + std::string(x)