mirror of
https://github.com/gabime/spdlog.git
synced 2025-09-29 09:59:33 +08:00
performance-unnecessary-value-param
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#include "includes.h"
|
||||
|
||||
// log to str and return it
|
||||
static std::string log_to_str(const std::string& msg, std::shared_ptr<spdlog::formatter> formatter = nullptr)
|
||||
static std::string log_to_str(const std::string& msg, const std::shared_ptr<spdlog::formatter>& formatter = nullptr)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
auto oss_sink = std::make_shared<spdlog::sinks::ostream_sink_mt>(oss);
|
||||
@@ -11,6 +11,7 @@ static std::string log_to_str(const std::string& msg, std::shared_ptr<spdlog::fo
|
||||
oss_logger.info(msg);
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
TEST_CASE("custom eol", "[pattern_formatter]")
|
||||
{
|
||||
std::string msg = "Hello custom eol test";
|
||||
@@ -38,7 +39,6 @@ TEST_CASE("level", "[pattern_formatter]")
|
||||
REQUIRE(log_to_str("Some message", formatter) == "[info] Some message\n");
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("short level", "[pattern_formatter]")
|
||||
{
|
||||
auto formatter = std::make_shared<spdlog::pattern_formatter>("[%L] %v", spdlog::pattern_time_type::local, "\n");
|
||||
@@ -51,19 +51,11 @@ TEST_CASE("name", "[pattern_formatter]")
|
||||
REQUIRE(log_to_str("Some message", formatter) == "[pattern_tester] Some message\n");
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("date MM/DD/YY ", "[pattern_formatter]")
|
||||
{
|
||||
using namespace::std::chrono;
|
||||
auto formatter = std::make_shared<spdlog::pattern_formatter>("%D %v", spdlog::pattern_time_type::local, "\n");
|
||||
auto now_tm = spdlog::details::os::localtime();
|
||||
std::stringstream oss;
|
||||
oss << std::setfill('0') << std::setw(2) << now_tm.tm_mon + 1 << "/" << now_tm.tm_mday << "/" << (now_tm.tm_year + 1900) % 1000 << " Some message\n";
|
||||
REQUIRE(log_to_str("Some message", formatter) == oss.str());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user