Moved default logger ctor to spdlog.cpp

This commit is contained in:
gabime 2024-12-06 15:15:26 +02:00
parent 8abaa0b383
commit 79df003092
3 changed files with 11 additions and 10 deletions

View File

@ -23,8 +23,9 @@ class thread_pool;
class SPDLOG_API context {
public:
context();
~context();
context() = default;
explicit context(std::unique_ptr<logger> global_logger);
~context() = default;
context(const context &) = delete;
context &operator=(const context &) = delete;

View File

@ -13,15 +13,10 @@
namespace spdlog {
namespace details {
context::context() {
#ifndef SPDLOG_DISABLE_GLOBAL_LOGGER
auto color_sink = std::make_shared<sinks::stdout_color_sink_mt>();
global_logger_ = std::make_shared<logger>(std::string(), std::move(color_sink));
#endif // SPDLOG_DISABLE_GLOBAL_LOGGER
context::context(std::unique_ptr<logger> global_logger) {
global_logger_ = std::move(global_logger);
}
context::~context() = default;
std::shared_ptr<logger> context::global_logger() {
return global_logger_;
}

View File

@ -12,7 +12,12 @@
namespace spdlog {
static std::shared_ptr<details::context> s_context = std::make_unique<details::context>();
#ifndef SPDLOG_DISABLE_GLOBAL_LOGGER
static std::shared_ptr s_context =
std::make_unique<details::context>(std::make_unique<logger>("", std::make_unique<sinks::stdout_color_sink_mt>()));
#else
static std::shared_ptr s_context = std::make_unique<details::context>();
#endif
void set_context(std::shared_ptr<details::context> context) { s_context = std::move(context); }