mirror of
https://github.com/gabime/spdlog.git
synced 2025-09-30 02:19:35 +08:00
* using API call instead of macro for toggling automatic registration
* added unit test for disabling automatic registration
This commit is contained in:
@@ -47,7 +47,7 @@ public:
|
||||
loggers_[logger_name] = std::move(new_logger);
|
||||
}
|
||||
|
||||
void init_with_global_defaults(std::shared_ptr<logger> new_logger)
|
||||
void initialize_logger(std::shared_ptr<logger> new_logger)
|
||||
{
|
||||
new_logger->set_formatter(formatter_->clone());
|
||||
|
||||
@@ -58,6 +58,11 @@ public:
|
||||
|
||||
new_logger->set_level(level_);
|
||||
new_logger->flush_on(flush_level_);
|
||||
|
||||
if (automatic_registration_)
|
||||
{
|
||||
register_logger(new_logger);
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<logger> get(const std::string &logger_name)
|
||||
@@ -215,6 +220,11 @@ public:
|
||||
return tp_mutex_;
|
||||
}
|
||||
|
||||
void set_automatic_registration(bool automatic_regsistration)
|
||||
{
|
||||
automatic_registration_ = automatic_regsistration;
|
||||
}
|
||||
|
||||
static registry &instance()
|
||||
{
|
||||
static registry s_instance;
|
||||
@@ -261,6 +271,7 @@ private:
|
||||
std::shared_ptr<thread_pool> tp_;
|
||||
std::unique_ptr<periodic_worker> periodic_flusher_;
|
||||
std::shared_ptr<logger> default_logger_;
|
||||
bool automatic_registration_ = true;
|
||||
};
|
||||
|
||||
} // namespace details
|
||||
|
Reference in New Issue
Block a user