1 #ifndef UTOPIA_CORE_LOGGING_HH
2 #define UTOPIA_CORE_LOGGING_HH
6 #include <spdlog/spdlog.h>
7 #include <spdlog/sinks/stdout_color_sinks.h>
32 const std::string name,
33 const spdlog::level::level_enum level,
34 const bool throw_on_exist =
true
37 auto logger = spdlog::get(name);
40 if (not logger || throw_on_exist) {
41 logger = spdlog::stdout_color_mt(name);
44 logger->set_level(level);
67 const spdlog::level::level_enum level_core = spdlog::level::warn,
68 const spdlog::level::level_enum level_data_io = spdlog::level::warn,
69 const spdlog::level::level_enum level_data_mngr = spdlog::level::warn,
70 const std::string& log_pattern =
""
77 spdlog::flush_on(spdlog::level::err);
81 if (not log_pattern.empty()) {
82 spdlog::set_pattern(log_pattern);
85 spdlog::set_pattern(
"[%T.%e] [%^%l%$] [%n] %v");
88 spdlog::get(
"core")->info(
"Set up loggers: core, data_io, data_mngr.");
const std::string log_data_mngr
Definition: logging.hh:20
void setup_loggers(const spdlog::level::level_enum level_core=spdlog::level::warn, const spdlog::level::level_enum level_data_io=spdlog::level::warn, const spdlog::level::level_enum level_data_mngr=spdlog::level::warn, const std::string &log_pattern="")
Set up and register the global loggers and set the global log pattern.
Definition: logging.hh:66
const std::string log_core
Definition: logging.hh:18
const std::string log_data_io
Definition: logging.hh:19
std::shared_ptr< spdlog::logger > init_logger(const std::string name, const spdlog::level::level_enum level, const bool throw_on_exist=true)
Initialize a logger with a certain name and log level.
Definition: logging.hh:31