Don't remove previous defaullt logger from registry in set_default_logger. Fix #3016

This commit is contained in:
gabime 2024-04-26 01:32:10 +03:00
parent a34e08c7ff
commit 3403f27898

View File

@ -123,11 +123,7 @@ SPDLOG_INLINE logger *registry::get_default_raw() { return default_logger_.get()
// set default logger.
// default logger is stored in default_logger_ (for faster retrieval) and in the loggers_ map.
SPDLOG_INLINE void registry::set_default_logger(std::shared_ptr<logger> new_default_logger) {
std::lock_guard<std::mutex> lock(logger_map_mutex_);
// remove previous default logger from the map
if (default_logger_ != nullptr) {
loggers_.erase(default_logger_->name());
}
std::lock_guard<std::mutex> lock(logger_map_mutex_);
if (new_default_logger != nullptr) {
loggers_[new_default_logger->name()] = new_default_logger;
}