1
0
mirror of https://github.com/gabime/spdlog.git synced 2025-01-27 18:06:31 +00:00

Compare commits

...

6 Commits

Author SHA1 Message Date
gabime
d09e03606c Fixed multiple clang-tidy warnings 2020-04-08 18:18:27 +03:00
gabime
b2017f5653 Fixed multiple clang-tidy warnings 2020-04-08 18:17:21 +03:00
gabime
c16eb80d7f Fixed multiple clang-tidy warnings 2020-04-08 17:04:10 +03:00
gabime
0c56f98a92 Fix .clang-tidy 2020-04-08 16:27:12 +03:00
gabime
490940cd53 Minor update to fmt_helper 2020-04-04 20:11:59 +03:00
gabime
92d27b0aa3 Minor update to fmt_helper 2020-04-04 20:11:17 +03:00
18 changed files with 124 additions and 97 deletions

View File

@ -1,16 +1,29 @@
Checks: '\
cppcoreguidelines-*,\
performance-*,\
-performance-unnecessary-value-param,\
modernize-*,\
-modernize-use-trailing-return-type,\
google-*,\
-google-runtime-references,\
misc-*,\
-misc-non-private-member-variables-in-classes,\
cert-*,\
readability-*,\
clang-analyzer-*'
Checks: 'cppcoreguidelines-*,
performance-*,
modernize-*,
google-*,
misc-*,
cert-*,
readability-*,
clang-analyzer-*,
-performance-unnecessary-value-param,
-modernize-use-trailing-return-type,
-google-runtime-references,
-misc-non-private-member-variables-in-classes,
-readability-braces-around-statements,
-google-readability-braces-around-statements,
-cppcoreguidelines-avoid-magic-numbers,
-readability-magic-numbers,
-readability-magic-numbers,
-cppcoreguidelines-pro-type-vararg,
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
-cppcoreguidelines-avoid-c-arrays,
-modernize-avoid-c-arrays,
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
-readability-named-parameter,
-cert-env33-c
'
WarningsAsErrors: ''
HeaderFilterRegex: '*spdlog/[^f].*'

View File

@ -21,10 +21,10 @@ namespace spdlog {
namespace cfg {
// search for SPDLOG_LEVEL= in the args and use it to init the levels
void load_argv_levels(int args, char **argv)
void load_argv_levels(int argc, const char **argv)
{
const std::string spdlog_level_prefix = "SPDLOG_LEVEL=";
for (int i = 1; i < args; i++)
for (int i = 1; i < argc; i++)
{
std::string arg = argv[i];
if (arg.find(spdlog_level_prefix) == 0)
@ -36,5 +36,10 @@ void load_argv_levels(int args, char **argv)
}
}
void load_argv_levels(int argc, char **argv)
{
load_argv_levels(argc, const_cast<const char**>(argv));
}
} // namespace cfg
} // namespace spdlog

View File

@ -31,10 +31,10 @@ inline void append_int(T n, memory_buf_t &dest)
}
template<typename T>
inline unsigned count_digits(T n)
inline unsigned int count_digits(T n)
{
using count_type = typename std::conditional<(sizeof(T) > sizeof(uint32_t)), uint64_t, uint32_t>::type;
return static_cast<unsigned>(fmt::internal::count_digits(static_cast<count_type>(n)));
return static_cast<unsigned int>(fmt::internal::count_digits(static_cast<count_type>(n)));
}
inline void pad2(int n, memory_buf_t &dest)

View File

@ -30,7 +30,11 @@ public:
~ansicolor_sink() override = default;
ansicolor_sink(const ansicolor_sink &other) = delete;
ansicolor_sink(ansicolor_sink &&other) = delete;
ansicolor_sink &operator=(const ansicolor_sink &other) = delete;
ansicolor_sink &operator=(ansicolor_sink &&other) = delete;
void set_color(level::level_enum color_level, string_view_t color);
void set_color_mode(color_mode mode);
bool should_color();

View File

@ -21,8 +21,14 @@ class base_sink : public sink
public:
base_sink();
explicit base_sink(std::unique_ptr<spdlog::formatter> formatter);
~base_sink() override = default;
base_sink(const base_sink &) = delete;
base_sink(base_sink &&) = delete;
base_sink &operator=(const base_sink &) = delete;
base_sink &operator=(base_sink &&) = delete;
void log(const details::log_msg &msg) final;
void flush() final;
void set_pattern(const std::string &pattern) final;

View File

@ -19,8 +19,12 @@ public:
using mutex_t = typename ConsoleMutex::mutex_t;
explicit stdout_sink_base(FILE *file);
~stdout_sink_base() override = default;
stdout_sink_base(const stdout_sink_base &other) = delete;
stdout_sink_base(stdout_sink_base &&other) = delete;
stdout_sink_base &operator=(const stdout_sink_base &other) = delete;
stdout_sink_base &operator=(stdout_sink_base &&other) = delete;
void log(const details::log_msg &msg) override;
void flush() override;

View File

@ -5,14 +5,13 @@
TEST_CASE("basic async test ", "[async]")
{
using namespace spdlog;
auto test_sink = std::make_shared<sinks::test_sink_mt>();
auto test_sink = std::make_shared<spdlog::sinks::test_sink_mt>();
size_t overrun_counter = 0;
size_t queue_size = 128;
size_t messages = 256;
{
auto tp = std::make_shared<details::thread_pool>(queue_size, 1);
auto logger = std::make_shared<async_logger>("as", test_sink, tp, async_overflow_policy::block);
auto tp = std::make_shared<spdlog::details::thread_pool>(queue_size, 1);
auto logger = std::make_shared<spdlog::async_logger>("as", test_sink, tp, spdlog::async_overflow_policy::block);
for (size_t i = 0; i < messages; i++)
{
logger->info("Hello message #{}", i);
@ -27,14 +26,13 @@ TEST_CASE("basic async test ", "[async]")
TEST_CASE("discard policy ", "[async]")
{
using namespace spdlog;
auto test_sink = std::make_shared<sinks::test_sink_mt>();
auto test_sink = std::make_shared<spdlog::sinks::test_sink_mt>();
test_sink->set_delay(std::chrono::milliseconds(1));
size_t queue_size = 4;
size_t messages = 1024;
auto tp = std::make_shared<details::thread_pool>(queue_size, 1);
auto logger = std::make_shared<async_logger>("as", test_sink, tp, async_overflow_policy::overrun_oldest);
auto tp = std::make_shared<spdlog::details::thread_pool>(queue_size, 1);
auto logger = std::make_shared<spdlog::async_logger>("as", test_sink, tp, spdlog::async_overflow_policy::overrun_oldest);
for (size_t i = 0; i < messages; i++)
{
logger->info("Hello message");
@ -45,13 +43,12 @@ TEST_CASE("discard policy ", "[async]")
TEST_CASE("discard policy using factory ", "[async]")
{
using namespace spdlog;
size_t queue_size = 4;
size_t messages = 1024;
spdlog::init_thread_pool(queue_size, 1);
auto logger = spdlog::create_async_nb<sinks::test_sink_mt>("as2");
auto test_sink = std::static_pointer_cast<sinks::test_sink_mt>(logger->sinks()[0]);
auto logger = spdlog::create_async_nb<spdlog::sinks::test_sink_mt>("as2");
auto test_sink = std::static_pointer_cast<spdlog::sinks::test_sink_mt>(logger->sinks()[0]);
test_sink->set_delay(std::chrono::milliseconds(1));
for (size_t i = 0; i < messages; i++)
@ -65,13 +62,12 @@ TEST_CASE("discard policy using factory ", "[async]")
TEST_CASE("flush", "[async]")
{
using namespace spdlog;
auto test_sink = std::make_shared<sinks::test_sink_mt>();
auto test_sink = std::make_shared<spdlog::sinks::test_sink_mt>();
size_t queue_size = 256;
size_t messages = 256;
{
auto tp = std::make_shared<details::thread_pool>(queue_size, 1);
auto logger = std::make_shared<async_logger>("as", test_sink, tp, async_overflow_policy::block);
auto tp = std::make_shared<spdlog::details::thread_pool>(queue_size, 1);
auto logger = std::make_shared<spdlog::async_logger>("as", test_sink, tp, spdlog::async_overflow_policy::block);
for (size_t i = 0; i < messages; i++)
{
logger->info("Hello message #{}", i);
@ -86,11 +82,9 @@ TEST_CASE("flush", "[async]")
TEST_CASE("async periodic flush", "[async]")
{
using namespace spdlog;
auto logger = spdlog::create_async<sinks::test_sink_mt>("as");
auto test_sink = std::static_pointer_cast<sinks::test_sink_mt>(logger->sinks()[0]);
auto logger = spdlog::create_async<spdlog::sinks::test_sink_mt>("as");
auto test_sink = std::static_pointer_cast<spdlog::sinks::test_sink_mt>(logger->sinks()[0]);
spdlog::flush_every(std::chrono::seconds(1));
std::this_thread::sleep_for(std::chrono::milliseconds(1100));
@ -101,13 +95,12 @@ TEST_CASE("async periodic flush", "[async]")
TEST_CASE("tp->wait_empty() ", "[async]")
{
using namespace spdlog;
auto test_sink = std::make_shared<sinks::test_sink_mt>();
auto test_sink = std::make_shared<spdlog::sinks::test_sink_mt>();
test_sink->set_delay(std::chrono::milliseconds(5));
size_t messages = 100;
auto tp = std::make_shared<details::thread_pool>(messages, 2);
auto logger = std::make_shared<async_logger>("as", test_sink, tp, async_overflow_policy::block);
auto tp = std::make_shared<spdlog::details::thread_pool>(messages, 2);
auto logger = std::make_shared<spdlog::async_logger>("as", test_sink, tp, spdlog::async_overflow_policy::block);
for (size_t i = 0; i < messages; i++)
{
logger->info("Hello message #{}", i);
@ -121,14 +114,13 @@ TEST_CASE("tp->wait_empty() ", "[async]")
TEST_CASE("multi threads", "[async]")
{
using namespace spdlog;
auto test_sink = std::make_shared<sinks::test_sink_mt>();
auto test_sink = std::make_shared<spdlog::sinks::test_sink_mt>();
size_t queue_size = 128;
size_t messages = 256;
size_t n_threads = 10;
{
auto tp = std::make_shared<details::thread_pool>(queue_size, 1);
auto logger = std::make_shared<async_logger>("as", test_sink, tp, async_overflow_policy::block);
auto tp = std::make_shared<spdlog::details::thread_pool>(queue_size, 1);
auto logger = std::make_shared<spdlog::async_logger>("as", test_sink, tp, spdlog::async_overflow_policy::block);
std::vector<std::thread> threads;
for (size_t i = 0; i < n_threads; i++)

View File

@ -27,7 +27,7 @@ TEST_CASE("argv1", "[cfg]")
{
spdlog::drop("l1");
const char *argv[] = {"ignore", "SPDLOG_LEVEL=l1=warn"};
load_argv_levels(2, const_cast<char **>(argv));
load_argv_levels(2, argv);
auto l1 = spdlog::create<spdlog::sinks::test_sink_st>("l1");
REQUIRE(l1->level() == spdlog::level::warn);
REQUIRE(spdlog::default_logger()->level() == spdlog::level::info);
@ -37,7 +37,7 @@ TEST_CASE("argv2", "[cfg]")
{
spdlog::drop("l1");
const char *argv[] = {"ignore", "SPDLOG_LEVEL=l1=warn,trace"};
load_argv_levels(2, const_cast<char **>(argv));
load_argv_levels(2, argv);
auto l1 = spdlog::create<test_sink_st>("l1");
REQUIRE(l1->level() == spdlog::level::warn);
REQUIRE(spdlog::default_logger()->level() == spdlog::level::trace);
@ -48,7 +48,7 @@ TEST_CASE("argv3", "[cfg]")
{
spdlog::drop("l1");
const char *argv[] = {"ignore", "SPDLOG_LEVEL="};
load_argv_levels(2, const_cast<char **>(argv));
load_argv_levels(2, argv);
auto l1 = spdlog::create<test_sink_st>("l1");
REQUIRE(l1->level() == spdlog::level::info);
REQUIRE(spdlog::default_logger()->level() == spdlog::level::info);
@ -58,7 +58,7 @@ TEST_CASE("argv4", "[cfg]")
{
spdlog::drop("l1");
const char *argv[] = {"ignore", "SPDLOG_LEVEL=junk"};
load_argv_levels(2, const_cast<char **>(argv));
load_argv_levels(2, argv);
auto l1 = spdlog::create<test_sink_st>("l1");
REQUIRE(l1->level() == spdlog::level::info);
}
@ -67,7 +67,7 @@ TEST_CASE("argv5", "[cfg]")
{
spdlog::drop("l1");
const char *argv[] = {"ignore", "ignore", "SPDLOG_LEVEL=l1=warn,trace"};
load_argv_levels(3, const_cast<char **>(argv));
load_argv_levels(3, argv);
auto l1 = spdlog::create<test_sink_st>("l1");
REQUIRE(l1->level() == spdlog::level::warn);
REQUIRE(spdlog::default_logger()->level() == spdlog::level::trace);
@ -78,7 +78,7 @@ TEST_CASE("argv6", "[cfg]")
{
spdlog::set_level(spdlog::level::err);
const char *argv[] = {""};
load_argv_levels(1, const_cast<char **>(argv));
load_argv_levels(1, argv);
REQUIRE(spdlog::default_logger()->level() == spdlog::level::err);
spdlog::set_level(spdlog::level::info);
}
@ -87,7 +87,7 @@ TEST_CASE("argv7", "[cfg]")
{
spdlog::set_level(spdlog::level::err);
const char *argv[] = {""};
load_argv_levels(0, const_cast<char **>(argv));
load_argv_levels(0, argv);
REQUIRE(spdlog::default_logger()->level() == spdlog::level::err);
spdlog::set_level(spdlog::level::info);
}

View File

@ -113,8 +113,7 @@ static void test_rotate(int days_to_run, uint16_t max_days, uint16_t expected_n_
using spdlog::log_clock;
using spdlog::details::log_msg;
using spdlog::sinks::daily_file_sink_st;
using namespace spdlog::details;
prepare_logdir();
std::string basename = "test_logs/daily_rotate.txt";

View File

@ -2,11 +2,11 @@
#include "spdlog/sinks/dup_filter_sink.h"
#include "test_sink.h"
using namespace spdlog;
using namespace spdlog::sinks;
TEST_CASE("dup_filter_test1", "[dup_filter_sink]")
{
using spdlog::sinks::dup_filter_sink_st;
using spdlog::sinks::test_sink_mt;
dup_filter_sink_st dup_sink{std::chrono::seconds{5}};
auto test_sink = std::make_shared<test_sink_mt>();
dup_sink.add_sink(test_sink);
@ -21,6 +21,9 @@ TEST_CASE("dup_filter_test1", "[dup_filter_sink]")
TEST_CASE("dup_filter_test2", "[dup_filter_sink]")
{
using spdlog::sinks::dup_filter_sink_st;
using spdlog::sinks::test_sink_mt;
dup_filter_sink_st dup_sink{std::chrono::seconds{0}};
auto test_sink = std::make_shared<test_sink_mt>();
dup_sink.add_sink(test_sink);
@ -36,6 +39,9 @@ TEST_CASE("dup_filter_test2", "[dup_filter_sink]")
TEST_CASE("dup_filter_test3", "[dup_filter_sink]")
{
using spdlog::sinks::dup_filter_sink_st;
using spdlog::sinks::test_sink_mt;
dup_filter_sink_st dup_sink{std::chrono::seconds{1}};
auto test_sink = std::make_shared<test_sink_mt>();
dup_sink.add_sink(test_sink);
@ -51,6 +57,9 @@ TEST_CASE("dup_filter_test3", "[dup_filter_sink]")
TEST_CASE("dup_filter_test4", "[dup_filter_sink]")
{
using spdlog::sinks::dup_filter_sink_mt;
using spdlog::sinks::test_sink_mt;
dup_filter_sink_mt dup_sink{std::chrono::milliseconds{10}};
auto test_sink = std::make_shared<test_sink_mt>();
dup_sink.add_sink(test_sink);
@ -63,6 +72,9 @@ TEST_CASE("dup_filter_test4", "[dup_filter_sink]")
TEST_CASE("dup_filter_test5", "[dup_filter_sink]")
{
using spdlog::sinks::dup_filter_sink_mt;
using spdlog::sinks::test_sink_mt;
dup_filter_sink_mt dup_sink{std::chrono::seconds{5}};
auto test_sink = std::make_shared<test_sink_mt>();
dup_sink.add_sink(test_sink);

View File

@ -7,10 +7,6 @@
class failing_sink : public spdlog::sinks::base_sink<std::mutex>
{
public:
failing_sink() = default;
~failing_sink() = default;
protected:
void sink_it_(const spdlog::details::log_msg &) final
{

View File

@ -4,9 +4,6 @@
#include "includes.h"
using spdlog::details::file_helper;
using spdlog::details::log_msg;
static const std::string target_filename = "test_logs/file_helper_test.txt";
static void write_with_helper(file_helper &helper, size_t howmany)
{
@ -21,6 +18,7 @@ TEST_CASE("file_helper_filename", "[file_helper::filename()]]")
prepare_logdir();
file_helper helper;
std::string target_filename = "test_logs/file_helper_test.txt";
helper.open(target_filename);
REQUIRE(helper.filename() == target_filename);
}
@ -28,6 +26,7 @@ TEST_CASE("file_helper_filename", "[file_helper::filename()]]")
TEST_CASE("file_helper_size", "[file_helper::size()]]")
{
prepare_logdir();
std::string target_filename = "test_logs/file_helper_test.txt";
size_t expected_size = 123;
{
file_helper helper;
@ -41,6 +40,7 @@ TEST_CASE("file_helper_size", "[file_helper::size()]]")
TEST_CASE("file_helper_reopen", "[file_helper::reopen()]]")
{
prepare_logdir();
std::string target_filename = "test_logs/file_helper_test.txt";
file_helper helper;
helper.open(target_filename);
write_with_helper(helper, 12);
@ -52,6 +52,7 @@ TEST_CASE("file_helper_reopen", "[file_helper::reopen()]]")
TEST_CASE("file_helper_reopen2", "[file_helper::reopen(false)]]")
{
prepare_logdir();
std::string target_filename = "test_logs/file_helper_test.txt";
size_t expected_size = 14;
file_helper helper;
helper.open(target_filename);
@ -71,7 +72,8 @@ static void test_split_ext(const char *fname, const char *expect_base, const cha
std::replace(filename.begin(), filename.end(), '/', '\\');
std::replace(expected_base.begin(), expected_base.end(), '/', '\\');
#endif
spdlog::filename_t basename, ext;
spdlog::filename_t basename;
spdlog::filename_t ext;
std::tie(basename, ext) = file_helper::split_by_extension(filename);
REQUIRE(basename == expected_base);
REQUIRE(ext == expected_ext);

View File

@ -54,8 +54,7 @@ TEST_CASE("rotating_file_logger1", "[rotating_logger]]")
}
logger->flush();
auto filename = basename;
require_message_count(filename, 10);
require_message_count(basename, 10);
}
TEST_CASE("rotating_file_logger2", "[rotating_logger]]")
@ -83,8 +82,8 @@ TEST_CASE("rotating_file_logger2", "[rotating_logger]]")
}
logger->flush();
auto filename = basename;
require_message_count(filename, 10);
require_message_count(basename, 10);
for (int i = 0; i < 1000; i++)
{
@ -93,7 +92,7 @@ TEST_CASE("rotating_file_logger2", "[rotating_logger]]")
}
logger->flush();
REQUIRE(get_filesize(filename) <= max_size);
REQUIRE(get_filesize(basename) <= max_size);
auto filename1 = basename + ".1";
REQUIRE(get_filesize(filename1) <= max_size);
}

View File

@ -21,11 +21,11 @@ TEST_CASE("basic_logging ", "[basic_logging]")
{
// const char
REQUIRE(log_info("Hello") == "Hello");
REQUIRE(log_info("") == "");
REQUIRE(log_info("").empty());
// std::string
REQUIRE(log_info(std::string("Hello")) == "Hello");
REQUIRE(log_info(std::string()) == std::string());
REQUIRE(log_info(std::string()).empty());
// Numbers
REQUIRE(log_info(5) == "5");
@ -37,8 +37,8 @@ TEST_CASE("basic_logging ", "[basic_logging]")
TEST_CASE("log_levels", "[log_levels]")
{
REQUIRE(log_info("Hello", spdlog::level::err) == "");
REQUIRE(log_info("Hello", spdlog::level::critical) == "");
REQUIRE(log_info("Hello", spdlog::level::err).empty());
REQUIRE(log_info("Hello", spdlog::level::critical).empty());
REQUIRE(log_info("Hello", spdlog::level::info) == "Hello");
REQUIRE(log_info("Hello", spdlog::level::debug) == "Hello");
REQUIRE(log_info("Hello", spdlog::level::trace) == "Hello");
@ -81,11 +81,9 @@ TEST_CASE("to_level_enum", "[convert_to_level_enum]")
TEST_CASE("periodic flush", "[periodic_flush]")
{
using namespace spdlog;
auto logger = spdlog::create<sinks::test_sink_mt>("periodic_flush");
auto test_sink = std::static_pointer_cast<sinks::test_sink_mt>(logger->sinks()[0]);
using spdlog::sinks::test_sink_mt;
auto logger = spdlog::create<test_sink_mt>("periodic_flush");
auto test_sink = std::static_pointer_cast<test_sink_mt>(logger->sinks()[0]);
spdlog::flush_every(std::chrono::seconds(1));
std::this_thread::sleep_for(std::chrono::milliseconds(1250));
@ -96,8 +94,8 @@ TEST_CASE("periodic flush", "[periodic_flush]")
TEST_CASE("clone-logger", "[clone]")
{
using namespace spdlog;
auto test_sink = std::make_shared<sinks::test_sink_mt>();
using spdlog::sinks::test_sink_mt;
auto test_sink = std::make_shared<test_sink_mt>();
auto logger = std::make_shared<spdlog::logger>("orig", test_sink);
logger->set_pattern("%v");
auto cloned = logger->clone("clone");
@ -118,10 +116,9 @@ TEST_CASE("clone-logger", "[clone]")
TEST_CASE("clone async", "[clone]")
{
using namespace spdlog;
using spdlog::sinks::test_sink_st;
spdlog::init_thread_pool(4, 1);
auto test_sink = std::make_shared<sinks::test_sink_st>();
auto test_sink = std::make_shared<test_sink_st>();
auto logger = std::make_shared<spdlog::async_logger>("orig", test_sink, spdlog::thread_pool());
logger->set_pattern("%v");
auto cloned = logger->clone("clone");

View File

@ -1,6 +1,5 @@
#include "includes.h"
using namespace std::chrono;
using std::chrono::milliseconds;
using test_clock = std::chrono::high_resolution_clock;
@ -13,7 +12,7 @@ TEST_CASE("dequeue-empty-nowait", "[mpmc_blocking_q]")
size_t q_size = 100;
milliseconds tolerance_wait(10);
spdlog::details::mpmc_blocking_queue<int> q(q_size);
int popped_item;
int popped_item = 0;
auto start = test_clock::now();
auto rv = q.dequeue_for(popped_item, milliseconds::zero());
@ -32,7 +31,7 @@ TEST_CASE("dequeue-empty-wait", "[mpmc_blocking_q]")
milliseconds tolerance_wait(250);
spdlog::details::mpmc_blocking_queue<int> q(q_size);
int popped_item;
int popped_item = 0;
auto start = test_clock::now();
auto rv = q.dequeue_for(popped_item, wait_ms);
auto delta_ms = millis_from(start);
@ -69,7 +68,7 @@ TEST_CASE("bad_queue", "[mpmc_blocking_q]")
spdlog::details::mpmc_blocking_queue<int> q(q_size);
q.enqueue_nowait(1);
REQUIRE(q.overrun_counter() == 1);
int i;
int i = 0;
REQUIRE(q.dequeue_for(i, milliseconds(0)) == false);
}
@ -77,7 +76,7 @@ TEST_CASE("empty_queue", "[mpmc_blocking_q]")
{
size_t q_size = 10;
spdlog::details::mpmc_blocking_queue<int> q(q_size);
int i;
int i = 0;
REQUIRE(q.dequeue_for(i, milliseconds(10)) == false);
}
@ -87,7 +86,7 @@ TEST_CASE("full_queue", "[mpmc_blocking_q]")
spdlog::details::mpmc_blocking_queue<int> q(q_size);
for (int i = 0; i < static_cast<int>(q_size); i++)
{
q.enqueue(std::move(i));
q.enqueue(i+0); // i+0 to force rvalue and avoid tidy warnings on the same time if we std::move(i) instead
}
q.enqueue_nowait(123456);

View File

@ -27,7 +27,7 @@ TEST_CASE("custom eol", "[pattern_formatter]")
TEST_CASE("empty format", "[pattern_formatter]")
{
REQUIRE(log_to_str("Some message", "", spdlog::pattern_time_type::local, "") == "");
REQUIRE(log_to_str("Some message", "", spdlog::pattern_time_type::local, "").empty());
}
TEST_CASE("empty format2", "[pattern_formatter]")
@ -308,7 +308,7 @@ TEST_CASE("clone-formatter-2", "[pattern_formatter]")
class custom_test_flag : public spdlog::custom_flag_formatter
{
public:
custom_test_flag(std::string txt)
explicit custom_test_flag(std::string txt)
: some_txt{std::move(txt)}
{}
@ -336,7 +336,6 @@ public:
// test clone with custom flag formatters
TEST_CASE("clone-custom_formatter", "[pattern_formatter]")
{
auto formatter_1 = std::make_shared<spdlog::pattern_formatter>();
formatter_1->add_flag<custom_test_flag>('t', "custom_output").set_pattern("[%n] [%t] %v");
auto formatter_2 = formatter_1->clone();
@ -358,9 +357,9 @@ TEST_CASE("clone-custom_formatter", "[pattern_formatter]")
//
#ifdef _WIN32
static const char *test_path = "\\a\\b\\myfile.cpp";
static const char *const test_path = "\\a\\b\\myfile.cpp";
#else
static const char *test_path = "/a/b//myfile.cpp";
static const char * const test_path = "/a/b//myfile.cpp";
#endif
TEST_CASE("short filename formatter-1", "[pattern_formatter]")

View File

@ -1,7 +1,7 @@
#include "includes.h"
static const char *tested_logger_name = "null_logger";
static const char *tested_logger_name2 = "null_logger2";
static const char * const tested_logger_name = "null_logger";
static const char * const tested_logger_name2 = "null_logger2";
#ifndef SPDLOG_NO_EXCEPTIONS
TEST_CASE("register_drop", "[registry]")

View File

@ -113,7 +113,7 @@ std::size_t count_files(const std::string &folder)
throw std::runtime_error("Failed open folder " + folder);
}
struct dirent *ep;
struct dirent *ep = nullptr;
while ((ep = readdir(dp)) != nullptr)
{
if (ep->d_name[0] != '.')