mirror of
https://github.com/gabime/spdlog.git
synced 2025-09-29 01:29: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:
@@ -93,3 +93,20 @@ TEST_CASE("set_default_logger(nullptr)", "[registry]")
|
||||
spdlog::set_default_logger(nullptr);
|
||||
REQUIRE_FALSE(spdlog::default_logger());
|
||||
}
|
||||
|
||||
TEST_CASE("disable automatic registration", "[registry]")
|
||||
{
|
||||
// set some global parameters
|
||||
spdlog::level::level_enum log_level = spdlog::level::level_enum::warn;
|
||||
spdlog::set_level(log_level);
|
||||
// but disable automatic registration
|
||||
spdlog::set_automatic_registration(false);
|
||||
auto logger1 = spdlog::create<spdlog::sinks::daily_file_sink_st>(tested_logger_name, "filename", 11, 59);
|
||||
auto logger2 = spdlog::create_async<spdlog::sinks::stdout_color_sink_mt>(tested_logger_name2);
|
||||
// loggers should not be part of the registry
|
||||
REQUIRE_FALSE(spdlog::get(tested_logger_name));
|
||||
REQUIRE_FALSE(spdlog::get(tested_logger_name2));
|
||||
// but make sure they are still initialized according to global defaults
|
||||
REQUIRE(logger1->level() == log_level);
|
||||
REQUIRE(logger2->level() == log_level);
|
||||
}
|
||||
|
Reference in New Issue
Block a user