2023-09-23 07:02:50 +08:00
|
|
|
#define SPDLOG_SOURCE_LOCATION
|
2023-09-16 06:06:21 +08:00
|
|
|
#include "includes.h"
|
|
|
|
#include "test_sink.h"
|
|
|
|
|
2023-09-23 07:02:50 +08:00
|
|
|
#if defined(SPDLOG_HAVE_STD_SOURCE_LOCATION) || defined(SPDLOG_HAVE_EXPERIMENTAL_SOURCE_LOCATION)
|
2023-09-16 06:06:21 +08:00
|
|
|
|
|
|
|
using spdlog::details::os::default_eol;
|
|
|
|
|
2023-09-25 21:05:07 +08:00
|
|
|
TEST_CASE("test_source_location", "[source_location]") {
|
2023-09-16 06:06:21 +08:00
|
|
|
std::ostringstream oss;
|
|
|
|
auto oss_sink = std::make_shared<spdlog::sinks::ostream_sink_st>(oss);
|
|
|
|
spdlog::logger oss_logger("oss", oss_sink);
|
|
|
|
oss_logger.set_pattern("%s:%# %v");
|
|
|
|
oss_logger.info("Hello {}", "source location");
|
2023-09-25 21:05:07 +08:00
|
|
|
REQUIRE(oss.str() ==
|
2023-09-25 21:29:32 +08:00
|
|
|
std::string("test_source_location.cpp:14 Hello source location") + default_eol);
|
2023-09-16 06:06:21 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|