Small refactoring to registry class
This commit is contained in:
parent
a6fbb3ef4c
commit
d99179f822
@ -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:
|
|||||||
|
|
||||||
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:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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_;
|
||||||
|
Loading…
Reference in New Issue
Block a user