Small refactoring to registry class

This commit is contained in:
gabime 2018-11-11 01:26:22 +02:00
parent a6fbb3ef4c
commit d99179f822

View File

@ -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_;