14#include <spdlog/common.h>
15#include <spdlog/sinks/stdout_color_sinks.h>
16#include <spdlog/spdlog.h>
32std::shared_ptr<spdlog::logger>
console = spdlog::stdout_color_mt(
"ogs");
34std::shared_ptr<spdlog::logger>
console = spdlog::stdout_color_st(
"ogs");
39 using namespace spdlog::level;
40 std::map<std::string, level_enum> string_to_log_level = {
41 {
"none", off}, {
"critical", critical}, {
"error", err}, {
"warn", warn},
42 {
"info", info}, {
"debug", debug}, {
"all", trace}};
44 auto const level = string_to_log_level.find(level_string);
45 if (level == string_to_log_level.end())
47 ERR(
"'{:s}' is not a valid log level!", level_string);
50 console->set_level(level->second);
51 spdlog::set_default_logger(
console);
57 spdlog::set_pattern(
"%^%l:%$ %v");
58 spdlog::set_error_handler(
59 [](
const std::string& msg)
61 std::cerr <<
"spdlog error: " << msg << std::endl;
62 OGS_FATAL(
"spdlog logger error occurred.");
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
void initOGSLogger(std::string const &log_level)
void setConsoleLogLevel(std::string const &level_string)
std::shared_ptr< spdlog::logger > console