Commit d99179f8 authored by gabime's avatar gabime

Small refactoring to registry class

parent a6fbb3ef
......@@ -42,9 +42,7 @@ public:
void register_logger(std::shared_ptr<logger> new_logger)
{
std::lock_guard<std::mutex> lock(logger_map_mutex_);
auto logger_name = new_logger->name();
throw_if_exists_(logger_name);
loggers_[logger_name] = std::move(new_logger);
register_logger_(std::move(new_logger));
}
void initialize_logger(std::shared_ptr<logger> new_logger)
......@@ -62,8 +60,7 @@ public:
if (automatic_registration_)
{
throw_if_exists_(new_logger->name());
loggers_[new_logger->name()] = std::move(new_logger);
register_logger_(std::move(new_logger));
}
}
......@@ -264,6 +261,13 @@ private:
}
}
void register_logger_(std::shared_ptr<logger> new_logger)
{
auto logger_name = new_logger->name();
throw_if_exists_(logger_name);
loggers_[logger_name] = std::move(new_logger);
}
std::mutex logger_map_mutex_, flusher_mutex_;
std::recursive_mutex tp_mutex_;
std::unordered_map<std::string, std::shared_ptr<logger>> loggers_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment