Commit d99179f8 authored by gabime's avatar gabime

Small refactoring to registry class

parent a6fbb3ef
...@@ -42,9 +42,7 @@ public: ...@@ -42,9 +42,7 @@ public:
void register_logger(std::shared_ptr<logger> new_logger) void register_logger(std::shared_ptr<logger> new_logger)
{ {
std::lock_guard<std::mutex> lock(logger_map_mutex_); std::lock_guard<std::mutex> lock(logger_map_mutex_);
auto logger_name = new_logger->name(); register_logger_(std::move(new_logger));
throw_if_exists_(logger_name);
loggers_[logger_name] = std::move(new_logger);
} }
void initialize_logger(std::shared_ptr<logger> new_logger) void initialize_logger(std::shared_ptr<logger> new_logger)
...@@ -62,8 +60,7 @@ public: ...@@ -62,8 +60,7 @@ public:
if (automatic_registration_) if (automatic_registration_)
{ {
throw_if_exists_(new_logger->name()); register_logger_(std::move(new_logger));
loggers_[new_logger->name()] = std::move(new_logger);
} }
} }
...@@ -264,6 +261,13 @@ private: ...@@ -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::mutex logger_map_mutex_, flusher_mutex_;
std::recursive_mutex tp_mutex_; std::recursive_mutex tp_mutex_;
std::unordered_map<std::string, std::shared_ptr<logger>> loggers_; 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