mirror of
https://github.com/gabime/spdlog.git
synced 2024-12-25 01:51:38 +08:00
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)
|
||||
{
|
||||
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_;
|
||||
|
Loading…
Reference in New Issue
Block a user