diff --git a/include/spdlog/cfg/log_levels.h b/include/spdlog/cfg/log_levels.h index fcfba2bd..0fce95e9 100644 --- a/include/spdlog/cfg/log_levels.h +++ b/include/spdlog/cfg/log_levels.h @@ -28,18 +28,21 @@ public: } } + void set_default(level::level_enum lvl) + { + default_level_ = lvl; + } + level::level_enum get(const std::string &logger_name) { auto it = levels_.find(logger_name); return it != levels_.end() ? it->second : default_level_; } - level::level_enum get() + level::level_enum get_default() { return default_level_; } - - }; } // namespace cfg } // namespace spdlog diff --git a/include/spdlog/details/registry-inl.h b/include/spdlog/details/registry-inl.h index 2202b4cc..a2a7e614 100644 --- a/include/spdlog/details/registry-inl.h +++ b/include/spdlog/details/registry-inl.h @@ -168,7 +168,7 @@ SPDLOG_INLINE void registry::set_level(level::level_enum log_level) { l.second->set_level(log_level); } - levels_.set("*", log_level); + levels_.set_default(log_level); } SPDLOG_INLINE void registry::flush_on(level::level_enum log_level) diff --git a/tests/test_cfg.cpp b/tests/test_cfg.cpp new file mode 100644 index 00000000..2bef6ef7 --- /dev/null +++ b/tests/test_cfg.cpp @@ -0,0 +1,10 @@ +#include "includes.h" +#include "test_sink.h" + +#include + +TEST_CASE("env", "[cfg]") +{ + spdlog::logger l{"l1"}; +} +