Fixed issue #61 (spdlog::set_level(...) does not affect loggers created afterwords)

This commit is contained in:
gabime 2015-03-18 23:31:17 +02:00
parent e9dbd4c0f9
commit 3556c87a51

View File

@ -41,7 +41,6 @@ namespace spdlog
{ {
namespace details namespace details
{ {
class registry class registry
{ {
public: public:
@ -94,7 +93,6 @@ public:
return create(logger_name, { sink }); return create(logger_name, { sink });
} }
void formatter(formatter_ptr f) void formatter(formatter_ptr f)
{ {
std::lock_guard<std::mutex> lock(_mutex); std::lock_guard<std::mutex> lock(_mutex);
@ -103,14 +101,12 @@ public:
l.second->set_formatter(_formatter); l.second->set_formatter(_formatter);
} }
void set_pattern(const std::string& pattern) void set_pattern(const std::string& pattern)
{ {
std::lock_guard<std::mutex> lock(_mutex); std::lock_guard<std::mutex> lock(_mutex);
_formatter = std::make_shared<pattern_formatter>(pattern); _formatter = std::make_shared<pattern_formatter>(pattern);
for (auto& l : _loggers) for (auto& l : _loggers)
l.second->set_formatter(_formatter); l.second->set_formatter(_formatter);
} }
void set_level(level::level_enum log_level) void set_level(level::level_enum log_level)
@ -118,6 +114,7 @@ public:
std::lock_guard<std::mutex> lock(_mutex); std::lock_guard<std::mutex> lock(_mutex);
for (auto& l : _loggers) for (auto& l : _loggers)
l.second->set_level(log_level); l.second->set_level(log_level);
_level = log_level;
} }
void set_async_mode(size_t q_size, const async_overflow_policy overflow_policy, const std::function<void()>& worker_warmup_cb) void set_async_mode(size_t q_size, const async_overflow_policy overflow_policy, const std::function<void()>& worker_warmup_cb)
@ -135,7 +132,6 @@ public:
_async_mode = false; _async_mode = false;
} }
static registry& instance() static registry& instance()
{ {
static registry s_instance; static registry s_instance;