2024-11-29 18:54:53 +08:00
|
|
|
#ifdef SPDLOG_NO_SOURCE_LOC
|
|
|
|
#undef SPDLOG_NO_SOURCE_LOC
|
|
|
|
#endif
|
2024-11-29 18:20:21 +08:00
|
|
|
|
2023-09-16 06:06:21 +08:00
|
|
|
#include "includes.h"
|
|
|
|
#include "test_sink.h"
|
|
|
|
|
|
|
|
|
2024-11-29 18:54:53 +08:00
|
|
|
// test with source location
|
2023-09-25 21:05:07 +08:00
|
|
|
TEST_CASE("test_source_location", "[source_location]") {
|
2024-11-29 18:54:53 +08:00
|
|
|
auto test_sink = std::make_shared<spdlog::sinks::test_sink_mt>();
|
|
|
|
auto logger = std::make_shared<spdlog::logger>("test", test_sink);
|
|
|
|
logger->set_pattern("%s:%# %v");
|
|
|
|
// test with source location with parameters
|
|
|
|
SPDLOG_LOGGER_CALL(logger, spdlog::level::info, "Hello {}", "source location");
|
|
|
|
REQUIRE(test_sink->lines().size() == 1);
|
|
|
|
REQUIRE(test_sink->lines()[0] == "test_source_location.cpp:14 Hello source location");
|
|
|
|
// test with source location without parameters
|
|
|
|
SPDLOG_LOGGER_CALL(logger, spdlog::level::info, "Hello");
|
|
|
|
REQUIRE(test_sink->lines().size() == 2);
|
|
|
|
REQUIRE(test_sink->lines()[1] == "test_source_location.cpp:18 Hello");
|
2023-09-16 06:06:21 +08:00
|
|
|
}
|
|
|
|
|
2024-11-29 18:54:53 +08:00
|
|
|
|
|
|
|
//REQUIRE(oss.str() == std::string("test_source_location.cpp:20 Hello source location") + default_eol);
|