mirror of
https://github.com/gabime/spdlog.git
synced 2025-09-28 17:19:34 +08:00
Upgrade to fmt 5.x
This commit is contained in:
@@ -1,11 +1,5 @@
|
||||
CXX ?= g++
|
||||
ifeq ($(STYLE),printf)
|
||||
$(info *** PRINTF STYLE ***)
|
||||
CXXFLAGS = -DSPDLOG_FMT_PRINTF -Wall -pedantic -std=c++11 -pthread -O3 -I../include
|
||||
else
|
||||
$(info *** FORMAT STYLE ***)
|
||||
CXXFLAGS = -Wall -pedantic -std=c++11 -pthread -O3 -I../include
|
||||
endif
|
||||
CXXFLAGS = -Wall -pedantic -std=c++11 -pthread -O3 -I../include
|
||||
LDPFALGS = -pthread
|
||||
|
||||
CPP_FILES := $(wildcard *.cpp)
|
||||
|
@@ -26,13 +26,8 @@ TEST_CASE("default_error_handler", "[errors]]")
|
||||
|
||||
auto logger = spdlog::create<spdlog::sinks::simple_file_sink_mt>("test-error", filename, true);
|
||||
logger->set_pattern("%v");
|
||||
#if !defined(SPDLOG_FMT_PRINTF)
|
||||
logger->info("Test message {} {}", 1);
|
||||
logger->info("Test message {}", 2);
|
||||
#else
|
||||
logger->info("Test message %d %d", 1);
|
||||
logger->info("Test message %d", 2);
|
||||
#endif
|
||||
logger->flush();
|
||||
|
||||
REQUIRE(file_contents(filename) == std::string("Test message 2\n"));
|
||||
@@ -50,11 +45,8 @@ TEST_CASE("custom_error_handler", "[errors]]")
|
||||
logger->flush_on(spdlog::level::info);
|
||||
logger->set_error_handler([=](const std::string &) { throw custom_ex(); });
|
||||
logger->info("Good message #1");
|
||||
#if !defined(SPDLOG_FMT_PRINTF)
|
||||
|
||||
REQUIRE_THROWS_AS(logger->info("Bad format msg {} {}", "xxx"), custom_ex);
|
||||
#else
|
||||
REQUIRE_THROWS_AS(logger->info("Bad format msg %s %s", "xxx"), custom_ex);
|
||||
#endif
|
||||
logger->info("Good message #2");
|
||||
REQUIRE(count_lines(filename) == 2);
|
||||
}
|
||||
@@ -91,11 +83,7 @@ TEST_CASE("async_error_handler", "[errors]]")
|
||||
ofs << err_msg;
|
||||
});
|
||||
logger->info("Good message #1");
|
||||
#if !defined(SPDLOG_FMT_PRINTF)
|
||||
logger->info("Bad format msg {} {}", "xxx");
|
||||
#else
|
||||
logger->info("Bad format msg %s %s", "xxx");
|
||||
#endif
|
||||
logger->info("Good message #2");
|
||||
spdlog::drop("logger"); // force logger to drain the queue and shutdown
|
||||
}
|
||||
|
@@ -11,13 +11,9 @@ TEST_CASE("simple_file_logger", "[simple_logger]]")
|
||||
auto logger = spdlog::create<spdlog::sinks::simple_file_sink_mt>("logger", filename);
|
||||
logger->set_pattern("%v");
|
||||
|
||||
#if !defined(SPDLOG_FMT_PRINTF)
|
||||
logger->info("Test message {}", 1);
|
||||
logger->info("Test message {}", 2);
|
||||
#else
|
||||
logger->info("Test message %d", 1);
|
||||
logger->info("Test message %d", 2);
|
||||
#endif
|
||||
|
||||
logger->flush();
|
||||
REQUIRE(file_contents(filename) == std::string("Test message 1\nTest message 2\n"));
|
||||
REQUIRE(count_lines(filename) == 2);
|
||||
@@ -35,13 +31,8 @@ TEST_CASE("flush_on", "[flush_on]]")
|
||||
logger->trace("Should not be flushed");
|
||||
REQUIRE(count_lines(filename) == 0);
|
||||
|
||||
#if !defined(SPDLOG_FMT_PRINTF)
|
||||
logger->info("Test message {}", 1);
|
||||
logger->info("Test message {}", 2);
|
||||
#else
|
||||
logger->info("Test message %d", 1);
|
||||
logger->info("Test message %d", 2);
|
||||
#endif
|
||||
logger->flush();
|
||||
REQUIRE(file_contents(filename) == std::string("Should not be flushed\nTest message 1\nTest message 2\n"));
|
||||
REQUIRE(count_lines(filename) == 3);
|
||||
@@ -56,11 +47,7 @@ TEST_CASE("rotating_file_logger1", "[rotating_logger]]")
|
||||
|
||||
for (int i = 0; i < 10; ++i)
|
||||
{
|
||||
#if !defined(SPDLOG_FMT_PRINTF)
|
||||
logger->info("Test message {}", i);
|
||||
#else
|
||||
logger->info("Test message %d", i);
|
||||
#endif
|
||||
}
|
||||
|
||||
logger->flush();
|
||||
@@ -82,11 +69,8 @@ TEST_CASE("rotating_file_logger2", "[rotating_logger]]")
|
||||
REQUIRE(count_lines(filename) == 10);
|
||||
for (int i = 0; i < 1000; i++)
|
||||
{
|
||||
#if !defined(SPDLOG_FMT_PRINTF)
|
||||
|
||||
logger->info("Test message {}", i);
|
||||
#else
|
||||
logger->info("Test message %d", i);
|
||||
#endif
|
||||
}
|
||||
|
||||
logger->flush();
|
||||
@@ -108,11 +92,7 @@ TEST_CASE("daily_logger", "[daily_logger]]")
|
||||
logger->flush_on(spdlog::level::info);
|
||||
for (int i = 0; i < 10; ++i)
|
||||
{
|
||||
#if !defined(SPDLOG_FMT_PRINTF)
|
||||
logger->info("Test message {}", i);
|
||||
#else
|
||||
logger->info("Test message %d", i);
|
||||
#endif
|
||||
}
|
||||
|
||||
auto filename = w.str();
|
||||
@@ -133,11 +113,8 @@ TEST_CASE("daily_logger with dateonly calculator", "[daily_logger_dateonly]]")
|
||||
auto logger = spdlog::create<sink_type>("logger", basename, 0, 0);
|
||||
for (int i = 0; i < 10; ++i)
|
||||
{
|
||||
#if !defined(SPDLOG_FMT_PRINTF)
|
||||
|
||||
logger->info("Test message {}", i);
|
||||
#else
|
||||
logger->info("Test message %d", i);
|
||||
#endif
|
||||
}
|
||||
logger->flush();
|
||||
auto filename = w.str();
|
||||
@@ -169,11 +146,7 @@ TEST_CASE("daily_logger with custom calculator", "[daily_logger_custom]]")
|
||||
auto logger = spdlog::create<sink_type>("logger", basename, 0, 0);
|
||||
for (int i = 0; i < 10; ++i)
|
||||
{
|
||||
#if !defined(SPDLOG_FMT_PRINTF)
|
||||
logger->info("Test message {}", i);
|
||||
#else
|
||||
logger->info("Test message %d", i);
|
||||
#endif
|
||||
}
|
||||
|
||||
logger->flush();
|
||||
|
@@ -31,16 +31,9 @@ TEST_CASE("debug and trace with format strings", "[macros]]")
|
||||
logger->set_pattern("%v");
|
||||
logger->set_level(spdlog::level::trace);
|
||||
|
||||
#if !defined(SPDLOG_FMT_PRINTF)
|
||||
SPDLOG_TRACE(logger, "Test message {}", 1);
|
||||
// SPDLOG_DEBUG(logger, "Test message 2");
|
||||
SPDLOG_DEBUG(logger, "Test message {}", 222);
|
||||
#else
|
||||
SPDLOG_TRACE(logger, "Test message %d", 1);
|
||||
// SPDLOG_DEBUG(logger, "Test message 2");
|
||||
SPDLOG_DEBUG(logger, "Test message %d", 222);
|
||||
#endif
|
||||
|
||||
logger->flush();
|
||||
|
||||
REQUIRE(ends_with(file_contents(filename), "Test message 222\n"));
|
||||
|
@@ -47,8 +47,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "bundled", "bundled", "{F0D4
|
||||
..\include\spdlog\fmt\bundled\ostream.h = ..\include\spdlog\fmt\bundled\ostream.h
|
||||
..\include\spdlog\fmt\bundled\posix.cc = ..\include\spdlog\fmt\bundled\posix.cc
|
||||
..\include\spdlog\fmt\bundled\posix.h = ..\include\spdlog\fmt\bundled\posix.h
|
||||
..\include\spdlog\fmt\bundled\printf.cc = ..\include\spdlog\fmt\bundled\printf.cc
|
||||
..\include\spdlog\fmt\bundled\printf.h = ..\include\spdlog\fmt\bundled\printf.h
|
||||
..\include\spdlog\fmt\bundled\time.h = ..\include\spdlog\fmt\bundled\time.h
|
||||
EndProjectSection
|
||||
EndProject
|
||||
|
Reference in New Issue
Block a user