#ifndef sk_LOGGER_HPP #define sk_LOGGER_HPP #include "commons.hpp" #include "Loc.hpp" #define LOGGER_TYPE(G) \ G(LOGGER_ERROR) namespace sk { SK_ENUM(Logger, LOGGER_TYPE); class Logger { public: explicit Logger(); virtual ~Logger(); template void log(Loc loc, LoggerType type, std::stringstream const& what); template void log(Loc loc, LoggerType type, std::string const& what); private: }; template void Logger::log(Loc loc, LoggerType type, std::stringstream const& what) { log(loc, type, what.str()); } template void Logger::log(Loc loc, LoggerType type, std::string const& what) { std::string type_str = std::string(LoggerTypeStr[type]) .substr(std::string("LOGGER_").size()); std::stringstream msg; switch (type) { case LOGGER_ERROR: { msg << loc.path().string() << ":" << loc.line(); msg << " " << type_str << " " << what; throw T {msg.str()}; } break; } } } #endif