| #include <ostream> | #include <ostream> | ||||
| #if _WIN32 | |||||
| #include <consoleapi2.h> | |||||
| static void set_utf8_output() { | |||||
| // 65'001 is the codepage id for UTF-8 output | |||||
| ::SetConsoleOutputCP(65'001); | |||||
| } | |||||
| #else | |||||
| static void set_utf8_output() { | |||||
| // Nothing on other platforms | |||||
| } | |||||
| #endif | |||||
| void dds::log::log_print(dds::log::level l, std::string_view msg) noexcept { | void dds::log::log_print(dds::log::level l, std::string_view msg) noexcept { | ||||
| static auto logger = [] { | |||||
| static auto logger_inst = [] { | |||||
| auto logger = spdlog::default_logger_raw(); | auto logger = spdlog::default_logger_raw(); | ||||
| logger->set_level(spdlog::level::trace); | logger->set_level(spdlog::level::trace); | ||||
| set_utf8_output(); | |||||
| return logger; | return logger; | ||||
| }(); | }(); | ||||
| neo_assert_always(invariant, false, "Invalid log level", msg, int(l)); | neo_assert_always(invariant, false, "Invalid log level", msg, int(l)); | ||||
| }(); | }(); | ||||
| logger->log(lvl, msg); | |||||
| logger_inst->log(lvl, "{}", msg); | |||||
| } | } |