spdlog/tests/test_source_location.cpp

22 lines
686 B
C++
Raw Normal View History

2024-11-29 18:20:21 +08:00
#ifndef SPDLOG_NO_SOURCE_LOC
2023-09-16 06:06:21 +08:00
#include "includes.h"
2023-09-29 05:45:09 +08:00
#include "spdlog/sinks/ostream_sink.h"
2023-09-16 06:06:21 +08:00
#include "test_sink.h"
using spdlog::details::os::default_eol;
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);
2024-11-29 18:20:21 +08:00
auto oss_logger = std::make_shared<spdlog::logger>("oss", oss_sink);
//spdlog::logger oss_logger("oss", oss_sink);
oss_logger->set_pattern("%s:%# %v");
2023-09-29 05:45:09 +08:00
2024-11-29 18:20:21 +08:00
SPDLOG_LOGGER_CALL(oss_logger, spdlog::level::info, "Hello {}", "source location");
REQUIRE(oss.str() == std::string("test_source_location.cpp:17 Hello source location") + default_eol);
2023-09-16 06:06:21 +08:00
}
#endif