mirror of
https://github.com/gabime/spdlog.git
synced 2025-01-31 09:39:15 +08:00
Moved default logger ctor to spdlog.cpp
This commit is contained in:
parent
8abaa0b383
commit
79df003092
@ -23,8 +23,9 @@ class thread_pool;
|
|||||||
|
|
||||||
class SPDLOG_API context {
|
class SPDLOG_API context {
|
||||||
public:
|
public:
|
||||||
context();
|
context() = default;
|
||||||
~context();
|
explicit context(std::unique_ptr<logger> global_logger);
|
||||||
|
~context() = default;
|
||||||
context(const context &) = delete;
|
context(const context &) = delete;
|
||||||
context &operator=(const context &) = delete;
|
context &operator=(const context &) = delete;
|
||||||
|
|
||||||
|
@ -13,15 +13,10 @@
|
|||||||
namespace spdlog {
|
namespace spdlog {
|
||||||
namespace details {
|
namespace details {
|
||||||
|
|
||||||
context::context() {
|
context::context(std::unique_ptr<logger> global_logger) {
|
||||||
#ifndef SPDLOG_DISABLE_GLOBAL_LOGGER
|
global_logger_ = std::move(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() = default;
|
|
||||||
|
|
||||||
std::shared_ptr<logger> context::global_logger() {
|
std::shared_ptr<logger> context::global_logger() {
|
||||||
return global_logger_;
|
return global_logger_;
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,12 @@
|
|||||||
|
|
||||||
namespace spdlog {
|
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); }
|
void set_context(std::shared_ptr<details::context> context) { s_context = std::move(context); }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user