Updated default API impl and tests

This commit is contained in:
gabime
2018-10-13 19:23:11 +03:00
parent 8131d3e127
commit f2f9f324ec
8 changed files with 131 additions and 62 deletions

View File

@@ -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");
}