mirror of
https://github.com/gabime/spdlog.git
synced 2025-10-02 11:29:01 +08:00
Reverted const qualifier to log_msg& args, fixed issue #849, and added counter tests
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
|
||||
#define SPDLOG_TRACE_ON
|
||||
#define SPDLOG_DEBUG_ON
|
||||
#define SPDLOG_ENABLE_MESSAGE_COUNTER
|
||||
|
||||
#include "spdlog/async.h"
|
||||
#include "spdlog/sinks/basic_file_sink.h"
|
||||
|
@@ -175,3 +175,19 @@ TEST_CASE("to_hex_no_delimiter", "[to_hex]")
|
||||
auto output = oss.str();
|
||||
REQUIRE(ends_with(output, "0000: 090A0B0CFFFF" + std::string(spdlog::details::os::default_eol)));
|
||||
}
|
||||
|
||||
TEST_CASE("message_counter", "[message_counter]")
|
||||
{
|
||||
std::ostringstream oss;
|
||||
auto oss_sink = std::make_shared<spdlog::sinks::ostream_sink_mt>(oss);
|
||||
spdlog::logger oss_logger("oss", oss_sink);
|
||||
oss_logger.set_pattern("%i %v");
|
||||
|
||||
oss_logger.info("Hello");
|
||||
REQUIRE(oss.str() == "000001 Hello" + std::string(spdlog::details::os::default_eol));
|
||||
|
||||
oss.str("");
|
||||
oss_logger.info("Hello again");
|
||||
|
||||
REQUIRE(oss.str() == "000002 Hello again" + std::string(spdlog::details::os::default_eol));
|
||||
}
|
||||
|
Reference in New Issue
Block a user