#include "logger.hpp" #include void Logger::init(bool toConsole, const std::string_view filePath) { using namespace boost::log; using namespace boost::posix_time; add_common_attributes(); if (toConsole) { add_console_log( std::clog, keywords::format = (expressions::stream << "[" << expressions::attr("TimeStamp") << "] " << "<" << trivial::severity << "> " << expressions::smessage) ); } if (!filePath.empty()) { add_file_log( keywords::file_name = filePath, keywords::auto_flush = true, keywords::format = (expressions::stream << "[" << expressions::attr("TimeStamp") << "] " << "<" << trivial::severity << "> " << expressions::smessage) ); } core::get()->set_filter(trivial::severity >= trivial::info); } void Logger::info(const std::string_view msg) { BOOST_LOG_TRIVIAL(info) << msg; } void Logger::warn(const std::string_view msg) { BOOST_LOG_TRIVIAL(warning) << msg; } void Logger::error(const std::string_view msg) { BOOST_LOG_TRIVIAL(error) << msg; } void Logger::debug(const std::string_view msg) { BOOST_LOG_TRIVIAL(debug) << msg; } void Logger::fatal(const std::string_view msg) { BOOST_LOG_TRIVIAL(fatal) << msg; }