mirror of
https://github.com/gabime/spdlog.git
synced 2025-09-28 09:09:35 +08:00
update clang format again
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
#if defined(__GNUC__) && __GNUC__ == 12
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" // Workaround for GCC 12
|
||||
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" // Workaround for GCC 12
|
||||
#endif
|
||||
#include <catch2/catch_all.hpp>
|
||||
#if defined(__GNUC__) && __GNUC__ == 12
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#if defined(__GNUC__) && __GNUC__ == 12
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" // Workaround for GCC 12
|
||||
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" // Workaround for GCC 12
|
||||
#endif
|
||||
|
||||
#include <catch2/catch_all.hpp>
|
||||
|
@@ -94,7 +94,6 @@ TEST_CASE("flush", "[async]") {
|
||||
}
|
||||
|
||||
TEST_CASE("async periodic flush", "[async]") {
|
||||
|
||||
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]);
|
||||
|
||||
|
@@ -3,7 +3,6 @@
|
||||
#include "spdlog/async.h"
|
||||
|
||||
TEST_CASE("bactrace1", "[bactrace]") {
|
||||
|
||||
using spdlog::sinks::test_sink_st;
|
||||
auto test_sink = std::make_shared<test_sink_st>();
|
||||
size_t backtrace_size = 5;
|
||||
@@ -13,8 +12,7 @@ TEST_CASE("bactrace1", "[bactrace]") {
|
||||
logger.enable_backtrace(backtrace_size);
|
||||
|
||||
logger.info("info message");
|
||||
for (int i = 0; i < 100; i++)
|
||||
logger.debug("debug message {}", i);
|
||||
for (int i = 0; i < 100; i++) logger.debug("debug message {}", i);
|
||||
|
||||
REQUIRE(test_sink->lines().size() == 1);
|
||||
REQUIRE(test_sink->lines()[0] == "info message");
|
||||
@@ -56,15 +54,14 @@ TEST_CASE("bactrace-async", "[bactrace]") {
|
||||
logger->enable_backtrace(backtrace_size);
|
||||
|
||||
logger->info("info message");
|
||||
for (int i = 0; i < 100; i++)
|
||||
logger->debug("debug message {}", i);
|
||||
for (int i = 0; i < 100; i++) logger->debug("debug message {}", i);
|
||||
|
||||
sleep_for_millis(100);
|
||||
REQUIRE(test_sink->lines().size() == 1);
|
||||
REQUIRE(test_sink->lines()[0] == "info message");
|
||||
|
||||
logger->dump_backtrace();
|
||||
sleep_for_millis(100); // give time for the async dump to complete
|
||||
sleep_for_millis(100); // give time for the async dump to complete
|
||||
REQUIRE(test_sink->lines().size() == backtrace_size + 3);
|
||||
REQUIRE(test_sink->lines()[1] == "****************** Backtrace Start ******************");
|
||||
REQUIRE(test_sink->lines()[2] == "debug message 95");
|
||||
|
@@ -19,7 +19,7 @@ TEST_CASE("create_dir", "[create_dir]") {
|
||||
REQUIRE(try_create_dir(SPDLOG_FILENAME_T("test_logs/dir1/dir1"),
|
||||
SPDLOG_FILENAME_T("test_logs/dir1/dir1")));
|
||||
REQUIRE(try_create_dir(SPDLOG_FILENAME_T("test_logs/dir1/dir1"),
|
||||
SPDLOG_FILENAME_T("test_logs/dir1/dir1"))); // test existing
|
||||
SPDLOG_FILENAME_T("test_logs/dir1/dir1"))); // test existing
|
||||
REQUIRE(try_create_dir(SPDLOG_FILENAME_T("test_logs/dir1///dir2//"),
|
||||
SPDLOG_FILENAME_T("test_logs/dir1/dir2")));
|
||||
REQUIRE(try_create_dir(SPDLOG_FILENAME_T("./test_logs/dir1/dir3"),
|
||||
|
@@ -37,7 +37,6 @@ TEST_CASE("daily_logger with dateonly calculator", "[daily_logger]") {
|
||||
|
||||
auto logger = spdlog::create<sink_type>("logger", basename, 0, 0);
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
|
||||
logger->info("Test message {}", i);
|
||||
}
|
||||
logger->flush();
|
||||
|
@@ -78,6 +78,6 @@ TEST_CASE("dup_filter_test5", "[dup_filter_sink]") {
|
||||
dup_sink.log(spdlog::details::log_msg{"test", spdlog::level::info, "message2"});
|
||||
|
||||
REQUIRE(test_sink->msg_counter() ==
|
||||
3); // skip 2 messages but log the "skipped.." message before message2
|
||||
3); // skip 2 messages but log the "skipped.." message before message2
|
||||
REQUIRE(test_sink->lines()[1] == "Skipped 2 duplicate messages..");
|
||||
}
|
||||
|
@@ -19,7 +19,7 @@ protected:
|
||||
};
|
||||
struct custom_ex {};
|
||||
|
||||
#if !defined(SPDLOG_USE_STD_FORMAT) // std formt doesn't fully support tuntime strings
|
||||
#if !defined(SPDLOG_USE_STD_FORMAT) // std formt doesn't fully support tuntime strings
|
||||
TEST_CASE("default_error_handler", "[errors]") {
|
||||
prepare_logdir();
|
||||
spdlog::filename_t filename = SPDLOG_FILENAME_T(SIMPLE_LOG);
|
||||
@@ -82,7 +82,7 @@ TEST_CASE("async_error_handler", "[errors]") {
|
||||
logger->info("Good message #1");
|
||||
logger->info(SPDLOG_FMT_RUNTIME("Bad format msg {} {}"), "xxx");
|
||||
logger->info("Good message #2");
|
||||
spdlog::drop("logger"); // force logger to drain the queue and shutdown
|
||||
spdlog::drop("logger"); // force logger to drain the queue and shutdown
|
||||
}
|
||||
spdlog::init_thread_pool(128, 1);
|
||||
require_message_count(SIMPLE_ASYNC_LOG, 2);
|
||||
@@ -100,12 +100,11 @@ TEST_CASE("async_error_handler2", "[errors]") {
|
||||
auto logger = spdlog::create_async<failing_sink>("failed_logger");
|
||||
logger->set_error_handler([=](const std::string &) {
|
||||
std::ofstream ofs("test_logs/custom_err2.txt");
|
||||
if (!ofs)
|
||||
throw std::runtime_error("Failed open test_logs/custom_err2.txt");
|
||||
if (!ofs) throw std::runtime_error("Failed open test_logs/custom_err2.txt");
|
||||
ofs << err_msg;
|
||||
});
|
||||
logger->info("Hello failure");
|
||||
spdlog::drop("failed_logger"); // force logger to drain the queue and shutdown
|
||||
spdlog::drop("failed_logger"); // force logger to drain the queue and shutdown
|
||||
}
|
||||
|
||||
spdlog::init_thread_pool(128, 1);
|
||||
|
@@ -72,4 +72,4 @@ TEST_CASE("eventlog", "[eventlog]") {
|
||||
"my critical message", EVENTLOG_ERROR_TYPE);
|
||||
}
|
||||
|
||||
#endif //_WIN32
|
||||
#endif //_WIN32
|
||||
|
@@ -85,7 +85,6 @@ TEST_CASE("rotating_file_logger2", "[rotating_logger]") {
|
||||
require_message_count(ROTATING_LOG, 10);
|
||||
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
|
||||
logger->info("Test message {}", i);
|
||||
}
|
||||
|
||||
|
@@ -12,7 +12,6 @@
|
||||
#define TEST_FILENAME "test_logs/simple_log"
|
||||
|
||||
TEST_CASE("debug and trace w/o format string", "[macros]") {
|
||||
|
||||
prepare_logdir();
|
||||
spdlog::filename_t filename = SPDLOG_FILENAME_T(TEST_FILENAME);
|
||||
|
||||
|
@@ -3,7 +3,6 @@
|
||||
|
||||
template <class T>
|
||||
std::string log_info(const T &what, spdlog::level::level_enum logger_level = spdlog::level::info) {
|
||||
|
||||
std::ostringstream oss;
|
||||
auto oss_sink = std::make_shared<spdlog::sinks::ostream_sink_mt>(oss);
|
||||
|
||||
|
@@ -22,7 +22,6 @@ TEST_CASE("dequeue-empty-nowait", "[mpmc_blocking_q]") {
|
||||
}
|
||||
|
||||
TEST_CASE("dequeue-empty-wait", "[mpmc_blocking_q]") {
|
||||
|
||||
size_t q_size = 100;
|
||||
milliseconds wait_ms(250);
|
||||
milliseconds tolerance_wait(250);
|
||||
@@ -59,7 +58,6 @@ TEST_CASE("dequeue-full-wait", "[mpmc_blocking_q]") {
|
||||
}
|
||||
|
||||
TEST_CASE("enqueue_nowait", "[mpmc_blocking_q]") {
|
||||
|
||||
size_t q_size = 1;
|
||||
spdlog::details::mpmc_blocking_queue<int> q(q_size);
|
||||
milliseconds tolerance_wait(10);
|
||||
@@ -96,8 +94,8 @@ TEST_CASE("full_queue", "[mpmc_blocking_q]") {
|
||||
size_t q_size = 100;
|
||||
spdlog::details::mpmc_blocking_queue<int> q(q_size);
|
||||
for (int i = 0; i < static_cast<int>(q_size); 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(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);
|
||||
|
@@ -65,5 +65,5 @@ protected:
|
||||
using test_sink_mt = test_sink<std::mutex>;
|
||||
using test_sink_st = test_sink<details::null_mutex>;
|
||||
|
||||
} // namespace sinks
|
||||
} // namespace spdlog
|
||||
} // namespace sinks
|
||||
} // namespace spdlog
|
||||
|
@@ -8,7 +8,7 @@ TEST_CASE("time_point1", "[time_point log_msg]") {
|
||||
|
||||
spdlog::source_loc source{};
|
||||
std::chrono::system_clock::time_point tp{std::chrono::system_clock::now()};
|
||||
test_sink->set_pattern("%T.%F"); // interested in the time_point
|
||||
test_sink->set_pattern("%T.%F"); // interested in the time_point
|
||||
|
||||
// all the following should have the same time
|
||||
test_sink->set_delay(std::chrono::milliseconds(10));
|
||||
@@ -22,7 +22,7 @@ TEST_CASE("time_point1", "[time_point log_msg]") {
|
||||
logger.log(tp, source, spdlog::level::info, "formatted message");
|
||||
logger.log(tp, source, spdlog::level::info, "formatted message");
|
||||
logger.log(source, spdlog::level::info,
|
||||
"formatted message"); // last line has different time_point
|
||||
"formatted message"); // last line has different time_point
|
||||
|
||||
// now the real test... that the times are the same.
|
||||
std::vector<std::string> lines = test_sink->lines();
|
||||
|
@@ -35,8 +35,7 @@ std::size_t count_lines(const std::string &filename) {
|
||||
|
||||
std::string line;
|
||||
size_t counter = 0;
|
||||
while (std::getline(ifs, line))
|
||||
counter++;
|
||||
while (std::getline(ifs, line)) counter++;
|
||||
return counter;
|
||||
}
|
||||
|
||||
@@ -74,10 +73,9 @@ std::size_t count_files(const std::string &folder) {
|
||||
// Start iterating over the files in the folder directory.
|
||||
HANDLE hFind = ::FindFirstFileA((folder + "\\*").c_str(), &ffd);
|
||||
if (hFind != INVALID_HANDLE_VALUE) {
|
||||
do // Managed to locate and create an handle to that folder.
|
||||
do // Managed to locate and create an handle to that folder.
|
||||
{
|
||||
if (ffd.cFileName[0] != '.')
|
||||
counter++;
|
||||
if (ffd.cFileName[0] != '.') counter++;
|
||||
} while (::FindNextFileA(hFind, &ffd) != 0);
|
||||
::FindClose(hFind);
|
||||
} else {
|
||||
@@ -97,8 +95,7 @@ std::size_t count_files(const std::string &folder) {
|
||||
|
||||
struct dirent *ep = nullptr;
|
||||
while ((ep = readdir(dp)) != nullptr) {
|
||||
if (ep->d_name[0] != '.')
|
||||
counter++;
|
||||
if (ep->d_name[0] != '.') counter++;
|
||||
}
|
||||
(void)closedir(dp);
|
||||
return counter;
|
||||
|
Reference in New Issue
Block a user