mirror of
https://github.com/gabime/spdlog.git
synced 2025-09-29 01:29:35 +08:00
Updated default API impl and tests
This commit is contained in:
@@ -198,35 +198,36 @@ TEST_CASE("default logger API", "[default logger]")
|
||||
auto oss_sink = std::make_shared<spdlog::sinks::ostream_sink_mt>(oss);
|
||||
|
||||
spdlog::set_default_logger(std::make_shared<spdlog::logger>("oss", oss_sink));
|
||||
spdlog::get()->set_pattern("%v");
|
||||
spdlog::set_pattern("*** %v");
|
||||
|
||||
spdlog::get()->set_level(spdlog::level::trace);
|
||||
spdlog::default_logger()->set_level(spdlog::level::trace);
|
||||
spdlog::trace("hello trace");
|
||||
REQUIRE(oss.str() == "hello trace" + std::string(spdlog::details::os::default_eol));
|
||||
REQUIRE(oss.str() == "*** hello trace" + std::string(spdlog::details::os::default_eol));
|
||||
|
||||
oss.str("");
|
||||
spdlog::debug("hello debug");
|
||||
REQUIRE(oss.str() == "hello debug" + std::string(spdlog::details::os::default_eol));
|
||||
REQUIRE(oss.str() == "*** hello debug" + std::string(spdlog::details::os::default_eol));
|
||||
|
||||
oss.str("");
|
||||
spdlog::info("Hello");
|
||||
REQUIRE(oss.str() == "Hello" + std::string(spdlog::details::os::default_eol));
|
||||
REQUIRE(oss.str() == "*** Hello" + std::string(spdlog::details::os::default_eol));
|
||||
|
||||
oss.str("");
|
||||
spdlog::warn("Hello again {}", 2);
|
||||
REQUIRE(oss.str() == "Hello again 2" + std::string(spdlog::details::os::default_eol));
|
||||
REQUIRE(oss.str() == "*** Hello again 2" + std::string(spdlog::details::os::default_eol));
|
||||
|
||||
oss.str("");
|
||||
spdlog::error(123);
|
||||
REQUIRE(oss.str() == "123" + std::string(spdlog::details::os::default_eol));
|
||||
REQUIRE(oss.str() == "*** 123" + std::string(spdlog::details::os::default_eol));
|
||||
|
||||
oss.str("");
|
||||
spdlog::critical(std::string("some string"));
|
||||
REQUIRE(oss.str() == "some string" + std::string(spdlog::details::os::default_eol));
|
||||
REQUIRE(oss.str() == "*** some string" + std::string(spdlog::details::os::default_eol));
|
||||
|
||||
oss.str("");
|
||||
spdlog::set_level(spdlog::level::info);
|
||||
spdlog::debug("should not be logged");
|
||||
REQUIRE(oss.str().empty());
|
||||
spdlog::drop_all();
|
||||
spdlog::set_pattern("%v");
|
||||
}
|
||||
|
Reference in New Issue
Block a user