Minor cleanup

This commit is contained in:
gabime 2024-12-06 10:27:00 +02:00
parent a8594177fa
commit 7fc6f1719c
3 changed files with 6 additions and 9 deletions

View File

@ -8,12 +8,9 @@
// If user requests a non-existing logger, nullptr will be returned // If user requests a non-existing logger, nullptr will be returned
// This class is thread safe // This class is thread safe
#include <chrono>
#include <functional>
#include <memory> #include <memory>
#include <mutex> #include <mutex>
#include <string> #include <string>
#include <string_view>
#include <unordered_map> #include <unordered_map>
#include "../common.h" #include "../common.h"

View File

@ -35,7 +35,7 @@ context::context() {
auto color_sink = std::make_shared<sinks::ansicolor_stdout_sink_mt>(); auto color_sink = std::make_shared<sinks::ansicolor_stdout_sink_mt>();
#endif #endif
const char *default_logger_name = ""; const char *default_logger_name = "";
default_logger_ = std::make_shared<spdlog::logger>(default_logger_name, std::move(color_sink)); default_logger_ = std::make_shared<logger>(default_logger_name, std::move(color_sink));
#endif // SPDLOG_DISABLE_DEFAULT_LOGGER #endif // SPDLOG_DISABLE_DEFAULT_LOGGER
} }

View File

@ -14,12 +14,12 @@ namespace spdlog {
void set_formatter(std::unique_ptr<spdlog::formatter> formatter) { void set_formatter(std::unique_ptr<formatter> formatter) {
default_logger_raw()->set_formatter(std::move(formatter)); default_logger_raw()->set_formatter(std::move(formatter));
} }
void set_pattern(std::string pattern, pattern_time_type time_type) { void set_pattern(std::string pattern, pattern_time_type time_type) {
set_formatter(std::make_unique<spdlog::pattern_formatter>(std::move(pattern), time_type)); set_formatter(std::make_unique<pattern_formatter>(std::move(pattern), time_type));
} }
level get_level() { return default_logger_raw()->log_level(); } level get_level() { return default_logger_raw()->log_level(); }
@ -35,11 +35,11 @@ void set_error_handler(void (*handler)(const std::string &msg)) { default_logger
void shutdown() { details::context::instance().shutdown(); } void shutdown() { details::context::instance().shutdown(); }
std::shared_ptr<spdlog::logger> default_logger() { return details::context::instance().default_logger(); } std::shared_ptr<logger> default_logger() { return details::context::instance().default_logger(); }
spdlog::logger *default_logger_raw() { return details::context::instance().get_default_raw(); } logger *default_logger_raw() { return details::context::instance().get_default_raw(); }
void set_default_logger(std::shared_ptr<spdlog::logger> default_logger) { void set_default_logger(std::shared_ptr<logger> default_logger) {
details::context::instance().set_default_logger(std::move(default_logger)); details::context::instance().set_default_logger(std::move(default_logger));
} }