Revert "Added a function to add callbacks that are called when a logger is registered (#2883)"

This reverts commit b6eeb7364c, since it causes deadlocks too easily for the users.
This commit is contained in:
gabime
2023-09-25 20:53:45 +03:00
parent b6eeb7364c
commit e5865186d4
5 changed files with 0 additions and 72 deletions

View File

@@ -110,30 +110,3 @@ TEST_CASE("disable automatic registration", "[registry]") {
spdlog::set_level(spdlog::level::info);
spdlog::set_automatic_registration(true);
}
TEST_CASE("add_on_registration_callback", "[registry]") {
std::vector<std::string> registered_logger_names;
auto on_registration_callback = [&](std::shared_ptr<spdlog::logger> logger)
{
registered_logger_names.push_back(logger->name());
};
spdlog::add_on_registration_callback(on_registration_callback);
auto captured_registration_logger1 = spdlog::create<spdlog::sinks::stdout_color_sink_mt>("captured_registration_logger1");
spdlog::set_automatic_registration(false);
auto non_captured_registration_logger1 = spdlog::create<spdlog::sinks::stdout_color_sink_mt>("non_captured_registration_logger1");
auto captured_registration_logger2 = spdlog::create<spdlog::sinks::stdout_color_sink_mt>("captured_registration_logger2");
spdlog::register_logger(captured_registration_logger2);
spdlog::drop_all_on_registration_callbacks();
auto non_captured_registration_logger2 = spdlog::create<spdlog::sinks::stdout_color_sink_mt>("non_captured_registration_logger2");
spdlog::register_logger(non_captured_registration_logger2);
// Check that only the automatically registered logged and the manually registered logger were captured
REQUIRE(registered_logger_names == std::vector<std::string>({"captured_registration_logger1", "captured_registration_logger2"}));
spdlog::set_level(spdlog::level::info);
spdlog::set_automatic_registration(true);
}