mirror of
https://github.com/gabime/spdlog.git
synced 2026-04-10 11:34:29 +08:00
Added apply_logger_env_levels (#2649)
This method applies levels which is set by environment variable `SPDLOG_LEVEL` to the a single controller. Usefull for loading configuration into manually created loggers.
This commit is contained in:
@@ -287,6 +287,14 @@ SPDLOG_INLINE registry ®istry::instance()
|
||||
return s_instance;
|
||||
}
|
||||
|
||||
SPDLOG_INLINE void registry::apply_logger_env_levels(std::shared_ptr<logger> new_logger)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(logger_map_mutex_);
|
||||
auto it = log_levels_.find(new_logger->name());
|
||||
auto new_level = it != log_levels_.end() ? it->second : global_log_level_;
|
||||
new_logger->set_level(new_level);
|
||||
}
|
||||
|
||||
SPDLOG_INLINE void registry::throw_if_exists_(const std::string &logger_name)
|
||||
{
|
||||
if (loggers_.find(logger_name) != loggers_.end())
|
||||
|
||||
@@ -91,6 +91,8 @@ public:
|
||||
|
||||
static registry &instance();
|
||||
|
||||
void apply_logger_env_levels(std::shared_ptr<logger> new_logger);
|
||||
|
||||
private:
|
||||
registry();
|
||||
~registry();
|
||||
|
||||
Reference in New Issue
Block a user