From 0a53eafe18d983c7c8ba4cadd02d0cc7f7308f28 Mon Sep 17 00:00:00 2001 From: gabime Date: Mon, 25 Sep 2023 16:40:36 +0300 Subject: [PATCH] update clang format again --- bench/async_bench.cpp | 17 +- bench/bench.cpp | 3 +- bench/formatter-bench.cpp | 1 - bench/latency.cpp | 12 +- bench/utils.h | 2 +- example/example.cpp | 28 +- include/spdlog/async.h | 7 +- include/spdlog/async_logger.h | 10 +- include/spdlog/cfg/argv.h | 4 +- include/spdlog/cfg/env.h | 4 +- include/spdlog/cfg/helpers-inl.h | 8 +- include/spdlog/cfg/helpers.h | 8 +- include/spdlog/common-inl.h | 4 +- include/spdlog/common.h | 50 +-- include/spdlog/details/backtracer-inl.h | 4 +- include/spdlog/details/backtracer.h | 4 +- include/spdlog/details/circular_q.h | 8 +- include/spdlog/details/console_globals.h | 4 +- include/spdlog/details/file_helper-inl.h | 8 +- include/spdlog/details/file_helper.h | 4 +- include/spdlog/details/fmt_helper.h | 22 +- include/spdlog/details/log_msg-inl.h | 4 +- include/spdlog/details/log_msg.h | 4 +- include/spdlog/details/log_msg_buffer-inl.h | 4 +- include/spdlog/details/log_msg_buffer.h | 4 +- include/spdlog/details/mpmc_blocking_q.h | 4 +- include/spdlog/details/null_mutex.h | 6 +- include/spdlog/details/os-inl.h | 70 ++- include/spdlog/details/os.h | 8 +- include/spdlog/details/periodic_worker-inl.h | 4 +- include/spdlog/details/periodic_worker.h | 6 +- include/spdlog/details/registry-inl.h | 13 +- include/spdlog/details/registry.h | 4 +- include/spdlog/details/synchronous_factory.h | 2 +- include/spdlog/details/tcp_client-windows.h | 12 +- include/spdlog/details/tcp_client.h | 12 +- include/spdlog/details/thread_pool-inl.h | 37 +- include/spdlog/details/thread_pool.h | 6 +- include/spdlog/details/udp_client-windows.h | 4 +- include/spdlog/details/udp_client.h | 4 +- include/spdlog/details/windows_include.h | 2 +- include/spdlog/fmt/bin_to_hex.h | 55 +-- include/spdlog/fmt/fmt.h | 4 +- include/spdlog/formatter.h | 2 +- include/spdlog/fwd.h | 2 +- include/spdlog/logger-inl.h | 11 +- include/spdlog/logger.h | 16 +- include/spdlog/pattern_formatter-inl.h | 423 +++++++++--------- include/spdlog/pattern_formatter.h | 9 +- include/spdlog/sinks/android_sink.h | 44 +- include/spdlog/sinks/ansicolor_sink-inl.h | 34 +- include/spdlog/sinks/ansicolor_sink.h | 4 +- include/spdlog/sinks/base_sink-inl.h | 4 +- include/spdlog/sinks/base_sink.h | 4 +- include/spdlog/sinks/basic_file_sink-inl.h | 4 +- include/spdlog/sinks/basic_file_sink.h | 4 +- include/spdlog/sinks/callback_sink.h | 4 +- include/spdlog/sinks/daily_file_sink.h | 36 +- include/spdlog/sinks/dist_sink.h | 4 +- include/spdlog/sinks/dup_filter_sink.h | 4 +- include/spdlog/sinks/hourly_file_sink.h | 4 +- include/spdlog/sinks/kafka_sink.h | 12 +- include/spdlog/sinks/mongo_sink.h | 24 +- include/spdlog/sinks/msvc_sink.h | 6 +- include/spdlog/sinks/null_sink.h | 4 +- include/spdlog/sinks/ostream_sink.h | 4 +- include/spdlog/sinks/qt_sinks.h | 30 +- include/spdlog/sinks/ringbuffer_sink.h | 4 +- include/spdlog/sinks/rotating_file_sink-inl.h | 20 +- include/spdlog/sinks/rotating_file_sink.h | 4 +- include/spdlog/sinks/sink.h | 4 +- include/spdlog/sinks/stdout_color_sinks-inl.h | 2 +- include/spdlog/sinks/stdout_color_sinks.h | 4 +- include/spdlog/sinks/stdout_sinks-inl.h | 24 +- include/spdlog/sinks/stdout_sinks.h | 6 +- include/spdlog/sinks/syslog_sink.h | 5 +- include/spdlog/sinks/systemd_sink.h | 4 +- include/spdlog/sinks/tcp_sink.h | 6 +- include/spdlog/sinks/udp_sink.h | 4 +- include/spdlog/sinks/win_eventlog_sink.h | 39 +- include/spdlog/sinks/wincolor_sink-inl.h | 21 +- include/spdlog/sinks/wincolor_sink.h | 4 +- include/spdlog/spdlog-inl.h | 2 +- include/spdlog/spdlog.h | 16 +- include/spdlog/stopwatch.h | 4 +- src/bundled_fmtlib_format.cpp | 10 +- src/color_sinks.cpp | 16 +- src/stdout_sinks.cpp | 16 +- tests/includes.h | 2 +- tests/main.cpp | 2 +- tests/test_async.cpp | 1 - tests/test_backtrace.cpp | 9 +- tests/test_create_dir.cpp | 2 +- tests/test_daily_logger.cpp | 1 - tests/test_dup_filter.cpp | 2 +- tests/test_errors.cpp | 9 +- tests/test_eventlog.cpp | 2 +- tests/test_file_logging.cpp | 1 - tests/test_macros.cpp | 1 - tests/test_misc.cpp | 1 - tests/test_mpmc_q.cpp | 6 +- tests/test_sink.h | 4 +- tests/test_time_point.cpp | 4 +- tests/utils.cpp | 11 +- 104 files changed, 713 insertions(+), 734 deletions(-) diff --git a/bench/async_bench.cpp b/bench/async_bench.cpp index 8d4d8106..a136c7bd 100644 --- a/bench/async_bench.cpp +++ b/bench/async_bench.cpp @@ -35,16 +35,15 @@ void bench_mt(int howmany, std::shared_ptr log, int thread_count #ifdef _MSC_VER #pragma warning(push) - #pragma warning(disable : 4996) // disable fopen warning under msvc -#endif // _MSC_VER + #pragma warning(disable : 4996) // disable fopen warning under msvc +#endif // _MSC_VER int count_lines(const char *filename) { int counter = 0; auto *infile = fopen(filename, "r"); int ch; while (EOF != (ch = getc(infile))) { - if ('\n' == ch) - counter++; + if ('\n' == ch) counter++; } fclose(infile); @@ -67,7 +66,6 @@ void verify_file(const char *filename, int expected_count) { #endif int main(int argc, char *argv[]) { - int howmany = 1000000; int queue_size = std::min(howmany + 2, 8192); int threads = 10; @@ -80,10 +78,8 @@ int main(int argc, char *argv[]) { return 0; } - if (argc > 1) - howmany = atoi(argv[1]); - if (argc > 2) - threads = atoi(argv[2]); + if (argc > 1) howmany = atoi(argv[1]); + if (argc > 2) threads = atoi(argv[2]); if (argc > 3) { queue_size = atoi(argv[3]); if (queue_size > 500000) { @@ -92,8 +88,7 @@ int main(int argc, char *argv[]) { } } - if (argc > 4) - iters = atoi(argv[4]); + if (argc > 4) iters = atoi(argv[4]); auto slot_size = sizeof(spdlog::details::async_msg); spdlog::info("-------------------------------------------------"); diff --git a/bench/bench.cpp b/bench/bench.cpp index c69471d3..609f4933 100644 --- a/bench/bench.cpp +++ b/bench/bench.cpp @@ -22,7 +22,7 @@ #include "utils.h" #include -#include // EXIT_FAILURE +#include // EXIT_FAILURE #include #include #include @@ -122,7 +122,6 @@ int main(int argc, char *argv[]) { int iters = 250000; size_t threads = 4; try { - if (argc > 1) { iters = std::stoi(argv[1]); } diff --git a/bench/formatter-bench.cpp b/bench/formatter-bench.cpp index 7c5c1843..375a154f 100644 --- a/bench/formatter-bench.cpp +++ b/bench/formatter-bench.cpp @@ -54,7 +54,6 @@ void bench_formatters() { } int main(int argc, char *argv[]) { - spdlog::set_pattern("[%^%l%$] %v"); if (argc != 2) { spdlog::error("Usage: {} (or \"all\" to bench all)", argv[0]); diff --git a/bench/latency.cpp b/bench/latency.cpp index cdb51359..f63251e3 100644 --- a/bench/latency.cpp +++ b/bench/latency.cpp @@ -49,8 +49,8 @@ void bench_global_logger(benchmark::State &state, std::shared_ptr logger) { int i = 0; - benchmark::DoNotOptimize(i); // prevent unused warnings - benchmark::DoNotOptimize(logger); // prevent unused warnings + benchmark::DoNotOptimize(i); // prevent unused warnings + benchmark::DoNotOptimize(logger); // prevent unused warnings for (auto _ : state) { SPDLOG_LOGGER_DEBUG(logger, "Hello logger: msg number {}...............", i++); } @@ -60,8 +60,8 @@ void bench_disabled_macro_global_logger(benchmark::State &state, std::shared_ptr logger) { spdlog::set_default_logger(std::move(logger)); int i = 0; - benchmark::DoNotOptimize(i); // prevent unused warnings - benchmark::DoNotOptimize(logger); // prevent unused warnings + benchmark::DoNotOptimize(i); // prevent unused warnings + benchmark::DoNotOptimize(logger); // prevent unused warnings for (auto _ : state) { SPDLOG_DEBUG("Hello logger: msg number {}...............", i++); } @@ -79,7 +79,7 @@ void bench_dev_null() { ->UseRealTime(); spdlog::drop("/dev/null_mt"); } -#endif // __linux__ +#endif // __linux__ int main(int argc, char *argv[]) { using spdlog::sinks::null_sink_mt; @@ -123,7 +123,7 @@ int main(int argc, char *argv[]) { #ifdef __linux bench_dev_null(); -#endif // __linux__ +#endif // __linux__ if (full_bench) { // basic_st diff --git a/bench/utils.h b/bench/utils.h index 0f52e700..1828fc08 100644 --- a/bench/utils.h +++ b/bench/utils.h @@ -29,4 +29,4 @@ inline std::string format(const double &value) { return ss.str(); } -} // namespace utils +} // namespace utils diff --git a/example/example.cpp b/example/example.cpp index d491a4da..aeff6d76 100644 --- a/example/example.cpp +++ b/example/example.cpp @@ -28,8 +28,8 @@ void file_events_example(); void replace_default_logger_example(); #include "spdlog/spdlog.h" -#include "spdlog/cfg/env.h" // support for loading levels from the environment variable -#include "spdlog/fmt/ostr.h" // support for user defined types +#include "spdlog/cfg/env.h" // support for loading levels from the environment variable +#include "spdlog/fmt/ostr.h" // support for user defined types int main(int, char *[]) { // Log levels can be loaded from argv/env using "SPDLOG_LEVEL" @@ -45,26 +45,26 @@ int main(int, char *[]) { spdlog::info("{:>8} aligned, {:<8} aligned", "right", "left"); // Runtime log levels - spdlog::set_level(spdlog::level::info); // Set global log level to info + spdlog::set_level(spdlog::level::info); // Set global log level to info spdlog::debug("This message should not be displayed!"); - spdlog::set_level(spdlog::level::trace); // Set specific logger's log level + spdlog::set_level(spdlog::level::trace); // Set specific logger's log level spdlog::debug("This message should be displayed.."); // Customize msg format for all loggers spdlog::set_pattern("[%H:%M:%S %z] [%^%L%$] [thread %t] %v"); spdlog::info("This an info message with custom format"); - spdlog::set_pattern("%+"); // back to default format + spdlog::set_pattern("%+"); // back to default format spdlog::set_level(spdlog::level::info); // Backtrace support // Loggers can store in a ring buffer all messages (including debug/trace) for later inspection. // When needed, call dump_backtrace() to see what happened: - spdlog::enable_backtrace(10); // create ring buffer with capacity of 10 messages + spdlog::enable_backtrace(10); // create ring buffer with capacity of 10 messages for (int i = 0; i < 100; i++) { - spdlog::debug("Backtrace message {}", i); // not logged.. + spdlog::debug("Backtrace message {}", i); // not logged.. } // e.g. if some error happened: - spdlog::dump_backtrace(); // log them now! + spdlog::dump_backtrace(); // log them now! try { stdout_logger_example(); @@ -267,7 +267,7 @@ struct my_type { : i(i){}; }; -#ifndef SPDLOG_USE_STD_FORMAT // when using fmtlib +#ifndef SPDLOG_USE_STD_FORMAT // when using fmtlib template <> struct fmt::formatter : fmt::formatter { auto format(my_type my, format_context &ctx) -> decltype(ctx.out()) { @@ -275,7 +275,7 @@ struct fmt::formatter : fmt::formatter { } }; -#else // when using std::format +#else // when using std::format template <> struct std::formatter : std::formatter { auto format(my_type my, format_context &ctx) const -> decltype(ctx.out()) { @@ -319,8 +319,9 @@ void android_example() { #include "spdlog/pattern_formatter.h" class my_formatter_flag : public spdlog::custom_flag_formatter { public: - void - format(const spdlog::details::log_msg &, const std::tm &, spdlog::memory_buf_t &dest) override { + void format(const spdlog::details::log_msg &, + const std::tm &, + spdlog::memory_buf_t &dest) override { std::string some_txt = "custom-flag"; dest.append(some_txt.data(), some_txt.data() + some_txt.size()); } @@ -331,8 +332,7 @@ public: }; void custom_flags_example() { - - using spdlog::details::make_unique; // for pre c++14 + using spdlog::details::make_unique; // for pre c++14 auto formatter = make_unique(); formatter->add_flag('*').set_pattern("[%n] [%*] [%^%l%$] %v"); // set the new formatter using spdlog::set_formatter(formatter) or diff --git a/include/spdlog/async.h b/include/spdlog/async.h index 76b93ed9..e96abd19 100644 --- a/include/spdlog/async.h +++ b/include/spdlog/async.h @@ -82,8 +82,9 @@ inline void init_thread_pool(size_t q_size, details::registry::instance().set_tp(std::move(tp)); } -inline void -init_thread_pool(size_t q_size, size_t thread_count, std::function on_thread_start) { +inline void init_thread_pool(size_t q_size, + size_t thread_count, + std::function on_thread_start) { init_thread_pool(q_size, thread_count, on_thread_start, [] {}); } @@ -96,4 +97,4 @@ inline void init_thread_pool(size_t q_size, size_t thread_count) { inline std::shared_ptr thread_pool() { return details::registry::instance().get_tp(); } -} // namespace spdlog +} // namespace spdlog diff --git a/include/spdlog/async_logger.h b/include/spdlog/async_logger.h index 1cb92ea5..846c4c6f 100644 --- a/include/spdlog/async_logger.h +++ b/include/spdlog/async_logger.h @@ -20,10 +20,10 @@ namespace spdlog { // Async overflow policy - block by default. enum class async_overflow_policy { - block, // Block until message can be enqueued - overrun_oldest, // Discard oldest message in the queue if full when trying to - // add new item. - discard_new // Discard new message if the queue is full when trying to add new item. + block, // Block until message can be enqueued + overrun_oldest, // Discard oldest message in the queue if full when trying to + // add new item. + discard_new // Discard new message if the queue is full when trying to add new item. }; namespace details { @@ -67,7 +67,7 @@ private: std::weak_ptr thread_pool_; async_overflow_policy overflow_policy_; }; -} // namespace spdlog +} // namespace spdlog #ifdef SPDLOG_HEADER_ONLY #include "async_logger-inl.h" diff --git a/include/spdlog/cfg/argv.h b/include/spdlog/cfg/argv.h index 8610e3ab..7de2f83e 100644 --- a/include/spdlog/cfg/argv.h +++ b/include/spdlog/cfg/argv.h @@ -36,5 +36,5 @@ inline void load_argv_levels(int argc, char **argv) { load_argv_levels(argc, const_cast(argv)); } -} // namespace cfg -} // namespace spdlog +} // namespace cfg +} // namespace spdlog diff --git a/include/spdlog/cfg/env.h b/include/spdlog/cfg/env.h index e445a1c6..6e554145 100644 --- a/include/spdlog/cfg/env.h +++ b/include/spdlog/cfg/env.h @@ -32,5 +32,5 @@ inline void load_env_levels() { } } -} // namespace cfg -} // namespace spdlog +} // namespace cfg +} // namespace spdlog diff --git a/include/spdlog/cfg/helpers-inl.h b/include/spdlog/cfg/helpers-inl.h index 9ee5e66e..93650a2e 100644 --- a/include/spdlog/cfg/helpers-inl.h +++ b/include/spdlog/cfg/helpers-inl.h @@ -89,7 +89,7 @@ SPDLOG_INLINE void load_levels(const std::string &input) { if (level == level::off && level_name != "off") { continue; } - if (logger_name.empty()) // no logger name indicate global level + if (logger_name.empty()) // no logger name indicate global level { global_level_found = true; global_level = level; @@ -102,6 +102,6 @@ SPDLOG_INLINE void load_levels(const std::string &input) { global_level_found ? &global_level : nullptr); } -} // namespace helpers -} // namespace cfg -} // namespace spdlog +} // namespace helpers +} // namespace cfg +} // namespace spdlog diff --git a/include/spdlog/cfg/helpers.h b/include/spdlog/cfg/helpers.h index bf18d253..c0238189 100644 --- a/include/spdlog/cfg/helpers.h +++ b/include/spdlog/cfg/helpers.h @@ -19,11 +19,11 @@ namespace helpers { // turn off all logging except for logger1 and logger2: "off,logger1=debug,logger2=info" // SPDLOG_API void load_levels(const std::string &txt); -} // namespace helpers +} // namespace helpers -} // namespace cfg -} // namespace spdlog +} // namespace cfg +} // namespace spdlog #ifdef SPDLOG_HEADER_ONLY #include "helpers-inl.h" -#endif // SPDLOG_HEADER_ONLY +#endif // SPDLOG_HEADER_ONLY diff --git a/include/spdlog/common-inl.h b/include/spdlog/common-inl.h index 3865245b..a8a0453c 100644 --- a/include/spdlog/common-inl.h +++ b/include/spdlog/common-inl.h @@ -42,7 +42,7 @@ SPDLOG_INLINE spdlog::level::level_enum from_str(const std::string &name) SPDLOG } return level::off; } -} // namespace level +} // namespace level SPDLOG_INLINE spdlog_ex::spdlog_ex(std::string msg) : msg_(std::move(msg)) {} @@ -65,4 +65,4 @@ SPDLOG_INLINE void throw_spdlog_ex(const std::string &msg, int last_errno) { SPDLOG_INLINE void throw_spdlog_ex(std::string msg) { SPDLOG_THROW(spdlog_ex(std::move(msg))); } -} // namespace spdlog +} // namespace spdlog diff --git a/include/spdlog/common.h b/include/spdlog/common.h index 7d516dc6..c46c1531 100644 --- a/include/spdlog/common.h +++ b/include/spdlog/common.h @@ -31,26 +31,26 @@ #if defined(_WIN32) #ifdef spdlog_EXPORTS #define SPDLOG_API __declspec(dllexport) - #else // !spdlog_EXPORTS + #else // !spdlog_EXPORTS #define SPDLOG_API __declspec(dllimport) #endif - #else // !defined(_WIN32) + #else // !defined(_WIN32) #define SPDLOG_API __attribute__((visibility("default"))) #endif - #else // !defined(SPDLOG_SHARED_LIB) + #else // !defined(SPDLOG_SHARED_LIB) #define SPDLOG_API #endif #define SPDLOG_INLINE -#else // !defined(SPDLOG_COMPILED_LIB) +#else // !defined(SPDLOG_COMPILED_LIB) #define SPDLOG_API #define SPDLOG_HEADER_ONLY #define SPDLOG_INLINE inline -#endif // #ifdef SPDLOG_COMPILED_LIB +#endif // #ifdef SPDLOG_COMPILED_LIB #include #if !defined(SPDLOG_USE_STD_FORMAT) && \ - FMT_VERSION >= 80000 // backward compatibility with fmt versions older than 8 + FMT_VERSION >= 80000 // backward compatibility with fmt versions older than 8 #define SPDLOG_FMT_RUNTIME(format_string) fmt::runtime(format_string) #define SPDLOG_FMT_STRING(format_string) FMT_STRING(format_string) #if defined(SPDLOG_WCHAR_FILENAMES) || defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT) @@ -162,7 +162,7 @@ using wformat_string_t = std::wstring_view; #endif #endif #define SPDLOG_BUF_TO_STRING(x) x -#else // use fmt lib instead of std::format +#else // use fmt lib instead of std::format namespace fmt_lib = fmt; using string_view_t = fmt::basic_string_view; @@ -204,8 +204,8 @@ using wformat_string_t = fmt::wformat_string; #ifdef SPDLOG_WCHAR_TO_UTF8_SUPPORT #ifndef _WIN32 #error SPDLOG_WCHAR_TO_UTF8_SUPPORT only supported on windows - #endif // _WIN32 -#endif // SPDLOG_WCHAR_TO_UTF8_SUPPORT + #endif // _WIN32 +#endif // SPDLOG_WCHAR_TO_UTF8_SUPPORT template struct is_convertible_to_any_format_string @@ -271,7 +271,7 @@ SPDLOG_API const string_view_t &to_string_view(spdlog::level::level_enum l) SPDL SPDLOG_API const char *to_short_c_str(spdlog::level::level_enum l) SPDLOG_NOEXCEPT; SPDLOG_API spdlog::level::level_enum from_str(const std::string &name) SPDLOG_NOEXCEPT; -} // namespace level +} // namespace level // // Color mode used by sinks with color support. @@ -283,8 +283,8 @@ enum class color_mode { always, automatic, never }; // local time by default // enum class pattern_time_type { - local, // log localtime - utc // log utc + local, // log localtime + utc // log utc }; // @@ -333,24 +333,24 @@ namespace details { // to_string_view -SPDLOG_CONSTEXPR_FUNC spdlog::string_view_t -to_string_view(const memory_buf_t &buf) SPDLOG_NOEXCEPT { +SPDLOG_CONSTEXPR_FUNC spdlog::string_view_t to_string_view(const memory_buf_t &buf) + SPDLOG_NOEXCEPT { return spdlog::string_view_t{buf.data(), buf.size()}; } -SPDLOG_CONSTEXPR_FUNC spdlog::string_view_t -to_string_view(spdlog::string_view_t str) SPDLOG_NOEXCEPT { +SPDLOG_CONSTEXPR_FUNC spdlog::string_view_t to_string_view(spdlog::string_view_t str) + SPDLOG_NOEXCEPT { return str; } #if defined(SPDLOG_WCHAR_FILENAMES) || defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT) -SPDLOG_CONSTEXPR_FUNC spdlog::wstring_view_t -to_string_view(const wmemory_buf_t &buf) SPDLOG_NOEXCEPT { +SPDLOG_CONSTEXPR_FUNC spdlog::wstring_view_t to_string_view(const wmemory_buf_t &buf) + SPDLOG_NOEXCEPT { return spdlog::wstring_view_t{buf.data(), buf.size()}; } -SPDLOG_CONSTEXPR_FUNC spdlog::wstring_view_t -to_string_view(spdlog::wstring_view_t str) SPDLOG_NOEXCEPT { +SPDLOG_CONSTEXPR_FUNC spdlog::wstring_view_t to_string_view(spdlog::wstring_view_t str) + SPDLOG_NOEXCEPT { return str; } #endif @@ -362,14 +362,14 @@ inline fmt::basic_string_view to_string_view(fmt::basic_format_string= 202207L template -SPDLOG_CONSTEXPR_FUNC std::basic_string_view -to_string_view(std::basic_format_string fmt) SPDLOG_NOEXCEPT { +SPDLOG_CONSTEXPR_FUNC std::basic_string_view to_string_view( + std::basic_format_string fmt) SPDLOG_NOEXCEPT { return fmt.get(); } #endif // make_unique support for pre c++14 -#if __cplusplus >= 201402L // C++14 and beyond +#if __cplusplus >= 201402L // C++14 and beyond using std::enable_if_t; using std::make_unique; #else @@ -394,8 +394,8 @@ constexpr T conditional_static_cast(U value) { return value; } -} // namespace details -} // namespace spdlog +} // namespace details +} // namespace spdlog #ifdef SPDLOG_HEADER_ONLY #include "common-inl.h" diff --git a/include/spdlog/details/backtracer-inl.h b/include/spdlog/details/backtracer-inl.h index 5e57d1c2..43d10024 100644 --- a/include/spdlog/details/backtracer-inl.h +++ b/include/spdlog/details/backtracer-inl.h @@ -59,5 +59,5 @@ SPDLOG_INLINE void backtracer::foreach_pop(std::function fun); }; -} // namespace details -} // namespace spdlog +} // namespace details +} // namespace spdlog #ifdef SPDLOG_HEADER_ONLY #include "backtracer-inl.h" diff --git a/include/spdlog/details/circular_q.h b/include/spdlog/details/circular_q.h index 76ac1f1c..ab068dff 100644 --- a/include/spdlog/details/circular_q.h +++ b/include/spdlog/details/circular_q.h @@ -24,7 +24,7 @@ public: circular_q() = default; explicit circular_q(size_t max_items) - : max_items_(max_items + 1) // one item is reserved as marker for full q + : max_items_(max_items + 1) // one item is reserved as marker for full q , v_(max_items_) {} @@ -46,7 +46,7 @@ public: v_[tail_] = std::move(item); tail_ = (tail_ + 1) % max_items_; - if (tail_ == head_) // overrun last item if full + if (tail_ == head_) // overrun last item if full { head_ = (head_ + 1) % max_items_; ++overrun_counter_; @@ -109,5 +109,5 @@ private: other.overrun_counter_ = 0; } }; -} // namespace details -} // namespace spdlog +} // namespace details +} // namespace spdlog diff --git a/include/spdlog/details/console_globals.h b/include/spdlog/details/console_globals.h index 649afb3e..9c552106 100644 --- a/include/spdlog/details/console_globals.h +++ b/include/spdlog/details/console_globals.h @@ -24,5 +24,5 @@ struct console_nullmutex { return s_mutex; } }; -} // namespace details -} // namespace spdlog +} // namespace details +} // namespace spdlog diff --git a/include/spdlog/details/file_helper-inl.h b/include/spdlog/details/file_helper-inl.h index b3474e5e..97215f50 100644 --- a/include/spdlog/details/file_helper-inl.h +++ b/include/spdlog/details/file_helper-inl.h @@ -127,8 +127,8 @@ SPDLOG_INLINE const filename_t &file_helper::filename() const { return filename_ // ".mylog" => (".mylog". "") // "my_folder/.mylog" => ("my_folder/.mylog", "") // "my_folder/.mylog.txt" => ("my_folder/.mylog", ".txt") -SPDLOG_INLINE std::tuple -file_helper::split_by_extension(const filename_t &fname) { +SPDLOG_INLINE std::tuple file_helper::split_by_extension( + const filename_t &fname) { auto ext_index = fname.rfind('.'); // no valid extension found - return whole path and empty string as @@ -147,5 +147,5 @@ file_helper::split_by_extension(const filename_t &fname) { return std::make_tuple(fname.substr(0, ext_index), fname.substr(ext_index)); } -} // namespace details -} // namespace spdlog +} // namespace details +} // namespace spdlog diff --git a/include/spdlog/details/file_helper.h b/include/spdlog/details/file_helper.h index 56d7d02c..f0e5d180 100644 --- a/include/spdlog/details/file_helper.h +++ b/include/spdlog/details/file_helper.h @@ -53,8 +53,8 @@ private: filename_t filename_; file_event_handlers event_handlers_; }; -} // namespace details -} // namespace spdlog +} // namespace details +} // namespace spdlog #ifdef SPDLOG_HEADER_ONLY #include "file_helper-inl.h" diff --git a/include/spdlog/details/fmt_helper.h b/include/spdlog/details/fmt_helper.h index 5dd62e14..61306003 100644 --- a/include/spdlog/details/fmt_helper.h +++ b/include/spdlog/details/fmt_helper.h @@ -53,14 +53,10 @@ SPDLOG_CONSTEXPR_FUNC unsigned int count_digits_fallback(T n) { // Integer division is slow so do it for a group of four digits instead // of for every digit. The idea comes from the talk by Alexandrescu // "Three Optimization Tips for C++". See speed-test for a comparison. - if (n < 10) - return count; - if (n < 100) - return count + 1; - if (n < 1000) - return count + 2; - if (n < 10000) - return count + 3; + if (n < 10) return count; + if (n < 100) return count + 1; + if (n < 1000) return count + 2; + if (n < 10000) return count + 3; n /= 10000u; count += 4; } @@ -86,11 +82,11 @@ inline unsigned int count_digits(T n) { } inline void pad2(int n, memory_buf_t &dest) { - if (n >= 0 && n < 100) // 0-99 + if (n >= 0 && n < 100) // 0-99 { dest.push_back(static_cast('0' + n / 10)); dest.push_back(static_cast('0' + n % 10)); - } else // unlikely, but just in case, let fmt deal with it + } else // unlikely, but just in case, let fmt deal with it { fmt_lib::format_to(std::back_inserter(dest), SPDLOG_FMT_STRING("{:02}"), n); } @@ -140,6 +136,6 @@ inline ToDuration time_fraction(log_clock::time_point tp) { return duration_cast(duration) - duration_cast(secs); } -} // namespace fmt_helper -} // namespace details -} // namespace spdlog +} // namespace fmt_helper +} // namespace details +} // namespace spdlog diff --git a/include/spdlog/details/log_msg-inl.h b/include/spdlog/details/log_msg-inl.h index 4923fb8e..aa3a9576 100644 --- a/include/spdlog/details/log_msg-inl.h +++ b/include/spdlog/details/log_msg-inl.h @@ -40,5 +40,5 @@ SPDLOG_INLINE log_msg::log_msg(string_view_t a_logger_name, spdlog::string_view_t msg) : log_msg(os::now(), source_loc{}, a_logger_name, lvl, msg) {} -} // namespace details -} // namespace spdlog +} // namespace details +} // namespace spdlog diff --git a/include/spdlog/details/log_msg.h b/include/spdlog/details/log_msg.h index 1833bd7f..87df1e83 100644 --- a/include/spdlog/details/log_msg.h +++ b/include/spdlog/details/log_msg.h @@ -32,8 +32,8 @@ struct SPDLOG_API log_msg { source_loc source; string_view_t payload; }; -} // namespace details -} // namespace spdlog +} // namespace details +} // namespace spdlog #ifdef SPDLOG_HEADER_ONLY #include "log_msg-inl.h" diff --git a/include/spdlog/details/log_msg_buffer-inl.h b/include/spdlog/details/log_msg_buffer-inl.h index 0441391c..2eb24285 100644 --- a/include/spdlog/details/log_msg_buffer-inl.h +++ b/include/spdlog/details/log_msg_buffer-inl.h @@ -50,5 +50,5 @@ SPDLOG_INLINE void log_msg_buffer::update_string_views() { payload = string_view_t{buffer.data() + logger_name.size(), payload.size()}; } -} // namespace details -} // namespace spdlog +} // namespace details +} // namespace spdlog diff --git a/include/spdlog/details/log_msg_buffer.h b/include/spdlog/details/log_msg_buffer.h index e5aeeb04..1143b3ba 100644 --- a/include/spdlog/details/log_msg_buffer.h +++ b/include/spdlog/details/log_msg_buffer.h @@ -24,8 +24,8 @@ public: log_msg_buffer &operator=(log_msg_buffer &&other) SPDLOG_NOEXCEPT; }; -} // namespace details -} // namespace spdlog +} // namespace details +} // namespace spdlog #ifdef SPDLOG_HEADER_ONLY #include "log_msg_buffer-inl.h" diff --git a/include/spdlog/details/mpmc_blocking_q.h b/include/spdlog/details/mpmc_blocking_q.h index 1780284d..5a474bf3 100644 --- a/include/spdlog/details/mpmc_blocking_q.h +++ b/include/spdlog/details/mpmc_blocking_q.h @@ -173,5 +173,5 @@ private: spdlog::details::circular_q q_; std::atomic discard_counter_{0}; }; -} // namespace details -} // namespace spdlog +} // namespace details +} // namespace spdlog diff --git a/include/spdlog/details/null_mutex.h b/include/spdlog/details/null_mutex.h index 1d59f82d..e3b32204 100644 --- a/include/spdlog/details/null_mutex.h +++ b/include/spdlog/details/null_mutex.h @@ -27,9 +27,9 @@ struct null_atomic_int { int exchange(int new_value, std::memory_order = std::memory_order_relaxed) { std::swap(new_value, value); - return new_value; // return value before the call + return new_value; // return value before the call } }; -} // namespace details -} // namespace spdlog +} // namespace details +} // namespace spdlog diff --git a/include/spdlog/details/os-inl.h b/include/spdlog/details/os-inl.h index 76b8414b..a154d41a 100644 --- a/include/spdlog/details/os-inl.h +++ b/include/spdlog/details/os-inl.h @@ -23,9 +23,9 @@ #ifdef _WIN32 #include - #include // for FlushFileBuffers - #include // for _get_osfhandle, _isatty, _fileno - #include // for _get_pid + #include // for FlushFileBuffers + #include // for _get_osfhandle, _isatty, _fileno + #include // for _get_pid #ifdef __MINGW32__ #include @@ -36,37 +36,37 @@ #include #endif - #include // for _mkdir/_wmkdir + #include // for _mkdir/_wmkdir -#else // unix +#else // unix #include #include #ifdef __linux__ - #include //Use gettid() syscall under linux to get thread id + #include //Use gettid() syscall under linux to get thread id #elif defined(_AIX) - #include // for pthread_getthrds_np + #include // for pthread_getthrds_np #elif defined(__DragonFly__) || defined(__FreeBSD__) - #include // for pthread_getthreadid_np + #include // for pthread_getthreadid_np #elif defined(__NetBSD__) - #include // for _lwp_self + #include // for _lwp_self #elif defined(__sun) - #include // for thr_self + #include // for thr_self #endif -#endif // unix +#endif // unix #if defined __APPLE__ #include #endif -#ifndef __has_feature // Clang - feature checking macros. - #define __has_feature(x) 0 // Compatibility with non-clang compilers. +#ifndef __has_feature // Clang - feature checking macros. + #define __has_feature(x) 0 // Compatibility with non-clang compilers. #endif namespace spdlog { @@ -74,7 +74,6 @@ namespace details { namespace os { SPDLOG_INLINE spdlog::log_clock::time_point now() SPDLOG_NOEXCEPT { - #if defined __linux__ && defined SPDLOG_CLOCK_COARSE timespec ts; ::clock_gettime(CLOCK_REALTIME_COARSE, &ts); @@ -87,7 +86,6 @@ SPDLOG_INLINE spdlog::log_clock::time_point now() SPDLOG_NOEXCEPT { #endif } SPDLOG_INLINE std::tm localtime(const std::time_t &time_tt) SPDLOG_NOEXCEPT { - #ifdef _WIN32 std::tm tm; ::localtime_s(&tm, &time_tt); @@ -104,7 +102,6 @@ SPDLOG_INLINE std::tm localtime() SPDLOG_NOEXCEPT { } SPDLOG_INLINE std::tm gmtime(const std::time_t &time_tt) SPDLOG_NOEXCEPT { - #ifdef _WIN32 std::tm tm; ::gmtime_s(&tm, &time_tt); @@ -137,7 +134,7 @@ SPDLOG_INLINE bool fopen_s(FILE **fp, const filename_t &filename, const filename } } #endif -#else // unix +#else // unix #if defined(SPDLOG_PREVENT_CHILD_FD) const int mode_flag = mode == SPDLOG_FILENAME_T("ab") ? O_APPEND : O_TRUNC; const int fd = @@ -186,7 +183,7 @@ SPDLOG_INLINE bool path_exists(const filename_t &filename) SPDLOG_NOEXCEPT { auto attribs = ::GetFileAttributesA(filename.c_str()); #endif return attribs != INVALID_FILE_ATTRIBUTES; -#else // common linux/unix all have the stat system call +#else // common linux/unix all have the stat system call struct stat buffer; return (::stat(filename.c_str(), &buffer) == 0); #endif @@ -205,20 +202,20 @@ SPDLOG_INLINE size_t filesize(FILE *f) { } #if defined(_WIN32) && !defined(__CYGWIN__) int fd = ::_fileno(f); - #if defined(_WIN64) // 64 bits + #if defined(_WIN64) // 64 bits __int64 ret = ::_filelengthi64(fd); if (ret >= 0) { return static_cast(ret); } - #else // windows 32 bits + #else // windows 32 bits long ret = ::_filelength(fd); if (ret >= 0) { return static_cast(ret); } #endif -#else // unix +#else // unix // OpenBSD and AIX doesn't compile with :: before the fileno(..) #if defined(__OpenBSD__) || defined(_AIX) int fd = fileno(f); @@ -232,7 +229,7 @@ SPDLOG_INLINE size_t filesize(FILE *f) { if (::fstat64(fd, &st) == 0) { return static_cast(st.st_size); } - #else // other unix or linux 32 bits or cygwin + #else // other unix or linux 32 bits or cygwin struct stat st; if (::fstat(fd, &st) == 0) { return static_cast(st.st_size); @@ -240,7 +237,7 @@ SPDLOG_INLINE size_t filesize(FILE *f) { #endif #endif throw_spdlog_ex("Failed getting file size from fd", errno); - return 0; // will not be reached. + return 0; // will not be reached. } #ifdef _MSC_VER @@ -249,7 +246,6 @@ SPDLOG_INLINE size_t filesize(FILE *f) { // Return utc offset in minutes or throw spdlog_ex on failure SPDLOG_INLINE int utc_minutes_offset(const std::tm &tm) { - #ifdef _WIN32 #if _WIN32_WINNT < _WIN32_WINNT_WS08 TIME_ZONE_INFORMATION tzinfo; @@ -258,8 +254,7 @@ SPDLOG_INLINE int utc_minutes_offset(const std::tm &tm) { DYNAMIC_TIME_ZONE_INFORMATION tzinfo; auto rv = ::GetDynamicTimeZoneInformation(&tzinfo); #endif - if (rv == TIME_ZONE_ID_INVALID) - throw_spdlog_ex("Failed getting timezone info. ", errno); + if (rv == TIME_ZONE_ID_INVALID) throw_spdlog_ex("Failed getting timezone info. ", errno); int offset = -tzinfo.Bias; if (tm.tm_isdst) { @@ -351,7 +346,7 @@ SPDLOG_INLINE size_t _thread_id() SPDLOG_NOEXCEPT { pthread_threadid_np(nullptr, &tid); #endif return static_cast(tid); -#else // Default to standard C++11 (other Unix) +#else // Default to standard C++11 (other Unix) return static_cast(std::hash()(std::this_thread::get_id())); #endif } @@ -360,7 +355,7 @@ SPDLOG_INLINE size_t _thread_id() SPDLOG_NOEXCEPT { SPDLOG_INLINE size_t thread_id() SPDLOG_NOEXCEPT { #if defined(SPDLOG_NO_TLS) return _thread_id(); -#else // cache thread id in tls +#else // cache thread id in tls static thread_local const size_t tid = _thread_id(); return tid; #endif @@ -388,7 +383,6 @@ SPDLOG_INLINE std::string filename_to_str(const filename_t &filename) { return f #endif SPDLOG_INLINE int pid() SPDLOG_NOEXCEPT { - #ifdef _WIN32 return conditional_static_cast(::GetCurrentProcessId()); #else @@ -430,7 +424,6 @@ SPDLOG_INLINE bool is_color_terminal() SPDLOG_NOEXCEPT { // Determine if the terminal attached // Source: https://github.com/agauniyal/rang/ SPDLOG_INLINE bool in_terminal(FILE *file) SPDLOG_NOEXCEPT { - #ifdef _WIN32 return ::_isatty(_fileno(file)) != 0; #else @@ -499,8 +492,8 @@ SPDLOG_INLINE void utf8_to_wstrbuf(string_view_t str, wmemory_buf_t &target) { throw_spdlog_ex( fmt_lib::format("MultiByteToWideChar failed. Last error: {}", ::GetLastError())); } -#endif // (defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT) || defined(SPDLOG_WCHAR_FILENAMES)) && - // defined(_WIN32) +#endif // (defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT) || defined(SPDLOG_WCHAR_FILENAMES)) && + // defined(_WIN32) // return true on success static SPDLOG_INLINE bool mkdir_(const filename_t &path) { @@ -537,7 +530,7 @@ SPDLOG_INLINE bool create_dir(const filename_t &path) { auto subdir = path.substr(0, token_pos); if (!subdir.empty() && !path_exists(subdir) && !mkdir_(subdir)) { - return false; // return error if failed creating dir + return false; // return error if failed creating dir } search_offset = token_pos + 1; } while (search_offset < path.size()); @@ -556,17 +549,16 @@ SPDLOG_INLINE filename_t dir_name(const filename_t &path) { } std::string SPDLOG_INLINE getenv(const char *field) { - #if defined(_MSC_VER) #if defined(__cplusplus_winrt) - return std::string{}; // not supported under uwp + return std::string{}; // not supported under uwp #else size_t len = 0; char buf[128]; bool ok = ::getenv_s(&len, buf, sizeof(buf), field) == 0; return ok ? buf : std::string{}; #endif -#else // revert to getenv +#else // revert to getenv char *buf = ::getenv(field); return buf ? buf : std::string{}; #endif @@ -582,6 +574,6 @@ SPDLOG_INLINE bool fsync(FILE *fp) { #endif } -} // namespace os -} // namespace details -} // namespace spdlog +} // namespace os +} // namespace details +} // namespace spdlog diff --git a/include/spdlog/details/os.h b/include/spdlog/details/os.h index 898b5464..b1069edc 100644 --- a/include/spdlog/details/os.h +++ b/include/spdlog/details/os.h @@ -3,7 +3,7 @@ #pragma once -#include // std::time_t +#include // std::time_t #include namespace spdlog { @@ -114,9 +114,9 @@ SPDLOG_API std::string getenv(const char *field); // Return true on success. SPDLOG_API bool fsync(FILE *fp); -} // namespace os -} // namespace details -} // namespace spdlog +} // namespace os +} // namespace details +} // namespace spdlog #ifdef SPDLOG_HEADER_ONLY #include "os-inl.h" diff --git a/include/spdlog/details/periodic_worker-inl.h b/include/spdlog/details/periodic_worker-inl.h index a9c9865e..18f11fbe 100644 --- a/include/spdlog/details/periodic_worker-inl.h +++ b/include/spdlog/details/periodic_worker-inl.h @@ -22,5 +22,5 @@ SPDLOG_INLINE periodic_worker::~periodic_worker() { } } -} // namespace details -} // namespace spdlog +} // namespace details +} // namespace spdlog diff --git a/include/spdlog/details/periodic_worker.h b/include/spdlog/details/periodic_worker.h index 10ba93c6..d05245cb 100644 --- a/include/spdlog/details/periodic_worker.h +++ b/include/spdlog/details/periodic_worker.h @@ -32,7 +32,7 @@ public: for (;;) { std::unique_lock lock(this->mutex_); if (this->cv_.wait_for(lock, interval, [this] { return !this->active_; })) { - return; // active_ == false, so exit this thread + return; // active_ == false, so exit this thread } callback_fun(); } @@ -49,8 +49,8 @@ private: std::mutex mutex_; std::condition_variable cv_; }; -} // namespace details -} // namespace spdlog +} // namespace details +} // namespace spdlog #ifdef SPDLOG_HEADER_ONLY #include "periodic_worker-inl.h" diff --git a/include/spdlog/details/registry-inl.h b/include/spdlog/details/registry-inl.h index a0a56e13..da4a7de9 100644 --- a/include/spdlog/details/registry-inl.h +++ b/include/spdlog/details/registry-inl.h @@ -19,7 +19,7 @@ #else #include #endif -#endif // SPDLOG_DISABLE_DEFAULT_LOGGER +#endif // SPDLOG_DISABLE_DEFAULT_LOGGER #include #include @@ -32,7 +32,6 @@ namespace details { SPDLOG_INLINE registry::registry() : formatter_(new pattern_formatter()) { - #ifndef SPDLOG_DISABLE_DEFAULT_LOGGER // create default logger (ansicolor_stdout_sink_mt or wincolor_stdout_sink_mt in windows). #ifdef _WIN32 @@ -45,7 +44,7 @@ SPDLOG_INLINE registry::registry() default_logger_ = std::make_shared(default_logger_name, std::move(color_sink)); loggers_[default_logger_name] = default_logger_; -#endif // SPDLOG_DISABLE_DEFAULT_LOGGER +#endif // SPDLOG_DISABLE_DEFAULT_LOGGER } SPDLOG_INLINE registry::~registry() = default; @@ -170,8 +169,8 @@ SPDLOG_INLINE void registry::set_error_handler(err_handler handler) { err_handler_ = std::move(handler); } -SPDLOG_INLINE void -registry::apply_all(const std::function)> &fun) { +SPDLOG_INLINE void registry::apply_all( + const std::function)> &fun) { std::lock_guard lock(logger_map_mutex_); for (auto &l : loggers_) { fun(l.second); @@ -262,5 +261,5 @@ SPDLOG_INLINE void registry::register_logger_(std::shared_ptr new_logger loggers_[logger_name] = std::move(new_logger); } -} // namespace details -} // namespace spdlog +} // namespace details +} // namespace spdlog diff --git a/include/spdlog/details/registry.h b/include/spdlog/details/registry.h index 17cc7218..56a6886e 100644 --- a/include/spdlog/details/registry.h +++ b/include/spdlog/details/registry.h @@ -114,8 +114,8 @@ private: size_t backtrace_n_messages_ = 0; }; -} // namespace details -} // namespace spdlog +} // namespace details +} // namespace spdlog #ifdef SPDLOG_HEADER_ONLY #include "registry-inl.h" diff --git a/include/spdlog/details/synchronous_factory.h b/include/spdlog/details/synchronous_factory.h index 21ded285..4bd5a51c 100644 --- a/include/spdlog/details/synchronous_factory.h +++ b/include/spdlog/details/synchronous_factory.h @@ -19,4 +19,4 @@ struct synchronous_factory { return new_logger; } }; -} // namespace spdlog +} // namespace spdlog diff --git a/include/spdlog/details/tcp_client-windows.h b/include/spdlog/details/tcp_client-windows.h index e74efa09..bf8f7b87 100644 --- a/include/spdlog/details/tcp_client-windows.h +++ b/include/spdlog/details/tcp_client-windows.h @@ -66,9 +66,9 @@ public: struct addrinfo hints {}; ZeroMemory(&hints, sizeof(hints)); - hints.ai_family = AF_UNSPEC; // To work with IPv4, IPv6, and so on - hints.ai_socktype = SOCK_STREAM; // TCP - hints.ai_flags = AI_NUMERICSERV; // port passed as as numeric value + hints.ai_family = AF_UNSPEC; // To work with IPv4, IPv6, and so on + hints.ai_socktype = SOCK_STREAM; // TCP + hints.ai_flags = AI_NUMERICSERV; // port passed as as numeric value hints.ai_protocol = 0; auto port_str = std::to_string(port); @@ -123,7 +123,7 @@ public: throw_winsock_error_("send failed", last_error); } - if (write_result == 0) // (probably should not happen but in any case..) + if (write_result == 0) // (probably should not happen but in any case..) { break; } @@ -131,5 +131,5 @@ public: } } }; -} // namespace details -} // namespace spdlog +} // namespace details +} // namespace spdlog diff --git a/include/spdlog/details/tcp_client.h b/include/spdlog/details/tcp_client.h index c323d78e..9d3c40d5 100644 --- a/include/spdlog/details/tcp_client.h +++ b/include/spdlog/details/tcp_client.h @@ -44,9 +44,9 @@ public: close(); struct addrinfo hints {}; memset(&hints, 0, sizeof(struct addrinfo)); - hints.ai_family = AF_UNSPEC; // To work with IPv4, IPv6, and so on - hints.ai_socktype = SOCK_STREAM; // TCP - hints.ai_flags = AI_NUMERICSERV; // port passed as as numeric value + hints.ai_family = AF_UNSPEC; // To work with IPv4, IPv6, and so on + hints.ai_socktype = SOCK_STREAM; // TCP + hints.ai_flags = AI_NUMERICSERV; // port passed as as numeric value hints.ai_protocol = 0; auto port_str = std::to_string(port); @@ -115,7 +115,7 @@ public: throw_spdlog_ex("write(2) failed", errno); } - if (write_result == 0) // (probably should not happen but in any case..) + if (write_result == 0) // (probably should not happen but in any case..) { break; } @@ -123,5 +123,5 @@ public: } } }; -} // namespace details -} // namespace spdlog +} // namespace details +} // namespace spdlog diff --git a/include/spdlog/details/thread_pool-inl.h b/include/spdlog/details/thread_pool-inl.h index b1c21dbb..17e01c09 100644 --- a/include/spdlog/details/thread_pool-inl.h +++ b/include/spdlog/details/thread_pool-inl.h @@ -19,8 +19,9 @@ SPDLOG_INLINE thread_pool::thread_pool(size_t q_max_items, std::function on_thread_stop) : q_(q_max_items) { if (threads_n == 0 || threads_n > 1000) { - throw_spdlog_ex("spdlog::thread_pool(): invalid threads_n param (valid " - "range is 1-1000)"); + throw_spdlog_ex( + "spdlog::thread_pool(): invalid threads_n param (valid " + "range is 1-1000)"); } for (size_t i = 0; i < threads_n; i++) { threads_.emplace_back([this, on_thread_start, on_thread_stop] { @@ -101,26 +102,26 @@ bool SPDLOG_INLINE thread_pool::process_next_msg_() { q_.dequeue(incoming_async_msg); switch (incoming_async_msg.msg_type) { - case async_msg_type::log: { - incoming_async_msg.worker_ptr->backend_sink_it_(incoming_async_msg); - return true; - } - case async_msg_type::flush: { - incoming_async_msg.worker_ptr->backend_flush_(); - return true; - } + case async_msg_type::log: { + incoming_async_msg.worker_ptr->backend_sink_it_(incoming_async_msg); + return true; + } + case async_msg_type::flush: { + incoming_async_msg.worker_ptr->backend_flush_(); + return true; + } - case async_msg_type::terminate: { - return false; - } + case async_msg_type::terminate: { + return false; + } - default: { - assert(false); - } + default: { + assert(false); + } } return true; } -} // namespace details -} // namespace spdlog +} // namespace details +} // namespace spdlog diff --git a/include/spdlog/details/thread_pool.h b/include/spdlog/details/thread_pool.h index cd6ac0f3..f22b0782 100644 --- a/include/spdlog/details/thread_pool.h +++ b/include/spdlog/details/thread_pool.h @@ -47,7 +47,7 @@ struct async_msg : log_msg_buffer { worker_ptr = std::move(other.worker_ptr); return *this; } -#else // (_MSC_VER) && _MSC_VER <= 1800 +#else // (_MSC_VER) && _MSC_VER <= 1800 async_msg(async_msg &&) = default; async_msg &operator=(async_msg &&) = default; #endif @@ -109,8 +109,8 @@ private: bool process_next_msg_(); }; -} // namespace details -} // namespace spdlog +} // namespace details +} // namespace spdlog #ifdef SPDLOG_HEADER_ONLY #include "thread_pool-inl.h" diff --git a/include/spdlog/details/udp_client-windows.h b/include/spdlog/details/udp_client-windows.h index 4d9d96b5..8b7c2232 100644 --- a/include/spdlog/details/udp_client-windows.h +++ b/include/spdlog/details/udp_client-windows.h @@ -94,5 +94,5 @@ public: } } }; -} // namespace details -} // namespace spdlog +} // namespace details +} // namespace spdlog diff --git a/include/spdlog/details/udp_client.h b/include/spdlog/details/udp_client.h index 39e4b449..95826f5d 100644 --- a/include/spdlog/details/udp_client.h +++ b/include/spdlog/details/udp_client.h @@ -77,5 +77,5 @@ public: } } }; -} // namespace details -} // namespace spdlog +} // namespace details +} // namespace spdlog diff --git a/include/spdlog/details/windows_include.h b/include/spdlog/details/windows_include.h index 43b8958d..bbab59b1 100644 --- a/include/spdlog/details/windows_include.h +++ b/include/spdlog/details/windows_include.h @@ -1,7 +1,7 @@ #pragma once #ifndef NOMINMAX - #define NOMINMAX // prevent windows redefining min/max + #define NOMINMAX // prevent windows redefining min/max #endif #ifndef WIN32_LEAN_AND_MEAN diff --git a/include/spdlog/fmt/bin_to_hex.h b/include/spdlog/fmt/bin_to_hex.h index b7440bba..c2998d57 100644 --- a/include/spdlog/fmt/bin_to_hex.h +++ b/include/spdlog/fmt/bin_to_hex.h @@ -56,7 +56,7 @@ private: It begin_, end_; size_t size_per_line_; }; -} // namespace details +} // namespace details // create a dump_info that wraps the given container template @@ -71,8 +71,8 @@ inline details::dump_info to_hex(const Conta #if __cpp_lib_span >= 202002L template -inline details::dump_info::iterator> -to_hex(const std::span &container, size_t size_per_line = 32) { +inline details::dump_info::iterator> to_hex( + const std::span &container, size_t size_per_line = 32) { using Container = std::span; static_assert(sizeof(typename Container::value_type) == 1, "sizeof(Container::value_type) != 1"); @@ -84,12 +84,13 @@ to_hex(const std::span &container, size_t size_per_line = 32) { // create dump_info from ranges template -inline details::dump_info -to_hex(const It range_begin, const It range_end, size_t size_per_line = 32) { +inline details::dump_info to_hex(const It range_begin, + const It range_end, + size_t size_per_line = 32) { return details::dump_info(range_begin, range_end, size_per_line); } -} // namespace spdlog +} // namespace spdlog namespace #ifdef SPDLOG_USE_STD_FORMAT @@ -105,7 +106,7 @@ struct formatter, char> { bool put_newlines = true; bool put_delimiters = true; bool use_uppercase = false; - bool put_positions = true; // position on start of each line + bool put_positions = true; // position on start of each line bool show_ascii = false; // parse the format string flags @@ -114,24 +115,24 @@ struct formatter, char> { auto it = ctx.begin(); while (it != ctx.end() && *it != '}') { switch (*it) { - case 'X': - use_uppercase = true; - break; - case 's': - put_delimiters = false; - break; - case 'p': - put_positions = false; - break; - case 'n': - put_newlines = false; - show_ascii = false; - break; - case 'a': - if (put_newlines) { - show_ascii = true; - } - break; + case 'X': + use_uppercase = true; + break; + case 's': + put_delimiters = false; + break; + case 'p': + put_positions = false; + break; + case 'n': + put_newlines = false; + show_ascii = false; + break; + case 'a': + if (put_newlines) { + show_ascii = true; + } + break; } ++it; @@ -185,7 +186,7 @@ struct formatter, char> { *inserter++ = hex_chars[(ch >> 4) & 0x0f]; *inserter++ = hex_chars[ch & 0x0f]; } - if (show_ascii) // add ascii to last line + if (show_ascii) // add ascii to last line { if (the_range.get_end() - the_range.get_begin() > size_per_line) { auto blank_num = size_per_line - (the_range.get_end() - start_of_line); @@ -220,4 +221,4 @@ struct formatter, char> { } } }; -} // namespace std +} // namespace std diff --git a/include/spdlog/fmt/fmt.h b/include/spdlog/fmt/fmt.h index 596e68c9..ae86940c 100644 --- a/include/spdlog/fmt/fmt.h +++ b/include/spdlog/fmt/fmt.h @@ -10,7 +10,7 @@ // By default spdlog include its own copy. // -#if defined(SPDLOG_USE_STD_FORMAT) // SPDLOG_USE_STD_FORMAT is defined - use std::format +#if defined(SPDLOG_USE_STD_FORMAT) // SPDLOG_USE_STD_FORMAT is defined - use std::format #include #elif !defined(SPDLOG_FMT_EXTERNAL) #if !defined(SPDLOG_COMPILED_LIB) && !defined(FMT_HEADER_ONLY) @@ -27,7 +27,7 @@ #include #include -#else // SPDLOG_FMT_EXTERNAL is defined - use external fmtlib +#else // SPDLOG_FMT_EXTERNAL is defined - use external fmtlib #include #include #endif diff --git a/include/spdlog/formatter.h b/include/spdlog/formatter.h index 7fbd52a5..4d482f82 100644 --- a/include/spdlog/formatter.h +++ b/include/spdlog/formatter.h @@ -14,4 +14,4 @@ public: virtual void format(const details::log_msg &msg, memory_buf_t &dest) = 0; virtual std::unique_ptr clone() const = 0; }; -} // namespace spdlog +} // namespace spdlog diff --git a/include/spdlog/fwd.h b/include/spdlog/fwd.h index d2588257..647b16bf 100644 --- a/include/spdlog/fwd.h +++ b/include/spdlog/fwd.h @@ -15,4 +15,4 @@ namespace level { enum level_enum : int; } -} // namespace spdlog +} // namespace spdlog diff --git a/include/spdlog/logger-inl.h b/include/spdlog/logger-inl.h index 8fe8fe01..5218fe4c 100644 --- a/include/spdlog/logger-inl.h +++ b/include/spdlog/logger-inl.h @@ -74,7 +74,7 @@ SPDLOG_INLINE void logger::set_formatter(std::unique_ptr f) { if (std::next(it) == sinks_.end()) { // last element - we can be move it. (*it)->set_formatter(std::move(f)); - break; // to prevent clang-tidy warning + break; // to prevent clang-tidy warning } else { (*it)->set_formatter(f->clone()); } @@ -121,8 +121,9 @@ SPDLOG_INLINE std::shared_ptr logger::clone(std::string logger_name) { } // protected methods -SPDLOG_INLINE void -logger::log_it_(const spdlog::details::log_msg &log_msg, bool log_enabled, bool traceback_enabled) { +SPDLOG_INLINE void logger::log_it_(const spdlog::details::log_msg &log_msg, + bool log_enabled, + bool traceback_enabled) { if (log_enabled) { sink_it_(log_msg); } @@ -185,7 +186,7 @@ SPDLOG_INLINE void logger::err_handler_(const std::string &msg) { auto tm_time = details::os::localtime(system_clock::to_time_t(now)); char date_buf[64]; std::strftime(date_buf, sizeof(date_buf), "%Y-%m-%d %H:%M:%S", &tm_time); -#if defined(USING_R) && defined(R_R_H) // if in R environment +#if defined(USING_R) && defined(R_R_H) // if in R environment REprintf("[*** LOG ERROR #%04zu ***] [%s] [%s] %s\n", err_counter, date_buf, name().c_str(), msg.c_str()); #else @@ -194,4 +195,4 @@ SPDLOG_INLINE void logger::err_handler_(const std::string &msg) { #endif } } -} // namespace spdlog +} // namespace spdlog diff --git a/include/spdlog/logger.h b/include/spdlog/logger.h index d1c81fda..f49bdc00 100644 --- a/include/spdlog/logger.h +++ b/include/spdlog/logger.h @@ -98,8 +98,10 @@ public: log(loc, lvl, "{}", msg); } - void - log(log_clock::time_point log_time, source_loc loc, level::level_enum lvl, string_view_t msg) { + void log(log_clock::time_point log_time, + source_loc loc, + level::level_enum lvl, + string_view_t msg) { bool log_enabled = should_log(lvl); bool traceback_enabled = tracer_.enabled(); if (!log_enabled && !traceback_enabled) { @@ -164,8 +166,10 @@ public: log(source_loc{}, lvl, fmt, std::forward(args)...); } - void - log(log_clock::time_point log_time, source_loc loc, level::level_enum lvl, wstring_view_t msg) { + void log(log_clock::time_point log_time, + source_loc loc, + level::level_enum lvl, + wstring_view_t msg) { bool log_enabled = should_log(lvl); bool traceback_enabled = tracer_.enabled(); if (!log_enabled && !traceback_enabled) { @@ -351,7 +355,7 @@ protected: } SPDLOG_LOGGER_CATCH(loc) } -#endif // SPDLOG_WCHAR_TO_UTF8_SUPPORT +#endif // SPDLOG_WCHAR_TO_UTF8_SUPPORT // log the given message (if the given log level is high enough), // and save backtrace (if backtrace is enabled). @@ -368,7 +372,7 @@ protected: void swap(logger &a, logger &b); -} // namespace spdlog +} // namespace spdlog #ifdef SPDLOG_HEADER_ONLY #include "logger-inl.h" diff --git a/include/spdlog/pattern_formatter-inl.h b/include/spdlog/pattern_formatter-inl.h index 1592b49f..a5875a11 100644 --- a/include/spdlog/pattern_formatter-inl.h +++ b/include/spdlog/pattern_formatter-inl.h @@ -51,7 +51,7 @@ public: auto half_pad = remaining_pad_ / 2; auto reminder = remaining_pad_ & 1; pad_it(half_pad); - remaining_pad_ = half_pad + reminder; // for the right side + remaining_pad_ = half_pad + reminder; // for the right side } } @@ -525,9 +525,9 @@ public: dest.push_back('+'); } - fmt_helper::pad2(total_minutes / 60, dest); // hours + fmt_helper::pad2(total_minutes / 60, dest); // hours dest.push_back(':'); - fmt_helper::pad2(total_minutes % 60, dest); // minutes + fmt_helper::pad2(total_minutes % 60, dest); // minutes } private: @@ -689,8 +689,8 @@ public: #ifdef _MSC_VER #pragma warning(push) - #pragma warning(disable : 4127) // consider using 'if constexpr' instead -#endif // _MSC_VER + #pragma warning(disable : 4127) // consider using 'if constexpr' instead +#endif // _MSC_VER static const char *basename(const char *filename) { // if the size is 2 (1 character + null terminator) we can use the more efficient strrchr // the branch will be elided by optimizations @@ -708,7 +708,7 @@ public: } #ifdef _MSC_VER #pragma warning(pop) -#endif // _MSC_VER +#endif // _MSC_VER void format(const details::log_msg &msg, const std::tm &, memory_buf_t &dest) override { if (msg.source.empty()) { @@ -867,7 +867,7 @@ private: memory_buf_t cached_datetime_; }; -} // namespace details +} // namespace details SPDLOG_INLINE pattern_formatter::pattern_formatter(std::string pattern, pattern_time_type time_type, @@ -954,240 +954,239 @@ SPDLOG_INLINE void pattern_formatter::handle_flag_(char flag, details::padding_i // process built-in flags switch (flag) { - case ('+'): // default formatter - formatters_.push_back(details::make_unique(padding)); - need_localtime_ = true; - break; + case ('+'): // default formatter + formatters_.push_back(details::make_unique(padding)); + need_localtime_ = true; + break; - case 'n': // logger name - formatters_.push_back(details::make_unique>(padding)); - break; + case 'n': // logger name + formatters_.push_back(details::make_unique>(padding)); + break; - case 'l': // level - formatters_.push_back(details::make_unique>(padding)); - break; + case 'l': // level + formatters_.push_back(details::make_unique>(padding)); + break; - case 'L': // short level - formatters_.push_back( - details::make_unique>(padding)); - break; + case 'L': // short level + formatters_.push_back( + details::make_unique>(padding)); + break; - case ('t'): // thread id - formatters_.push_back(details::make_unique>(padding)); - break; + case ('t'): // thread id + formatters_.push_back(details::make_unique>(padding)); + break; - case ('v'): // the message text - formatters_.push_back(details::make_unique>(padding)); - break; + case ('v'): // the message text + formatters_.push_back(details::make_unique>(padding)); + break; - case ('a'): // weekday - formatters_.push_back(details::make_unique>(padding)); - need_localtime_ = true; - break; + case ('a'): // weekday + formatters_.push_back(details::make_unique>(padding)); + need_localtime_ = true; + break; - case ('A'): // short weekday - formatters_.push_back(details::make_unique>(padding)); - need_localtime_ = true; - break; + case ('A'): // short weekday + formatters_.push_back(details::make_unique>(padding)); + need_localtime_ = true; + break; - case ('b'): - case ('h'): // month - formatters_.push_back(details::make_unique>(padding)); - need_localtime_ = true; - break; + case ('b'): + case ('h'): // month + formatters_.push_back(details::make_unique>(padding)); + need_localtime_ = true; + break; - case ('B'): // short month - formatters_.push_back(details::make_unique>(padding)); - need_localtime_ = true; - break; + case ('B'): // short month + formatters_.push_back(details::make_unique>(padding)); + need_localtime_ = true; + break; - case ('c'): // datetime - formatters_.push_back(details::make_unique>(padding)); - need_localtime_ = true; - break; + case ('c'): // datetime + formatters_.push_back(details::make_unique>(padding)); + need_localtime_ = true; + break; - case ('C'): // year 2 digits - formatters_.push_back(details::make_unique>(padding)); - need_localtime_ = true; - break; + case ('C'): // year 2 digits + formatters_.push_back(details::make_unique>(padding)); + need_localtime_ = true; + break; - case ('Y'): // year 4 digits - formatters_.push_back(details::make_unique>(padding)); - need_localtime_ = true; - break; + case ('Y'): // year 4 digits + formatters_.push_back(details::make_unique>(padding)); + need_localtime_ = true; + break; - case ('D'): - case ('x'): // datetime MM/DD/YY - formatters_.push_back(details::make_unique>(padding)); - need_localtime_ = true; - break; + case ('D'): + case ('x'): // datetime MM/DD/YY + formatters_.push_back(details::make_unique>(padding)); + need_localtime_ = true; + break; - case ('m'): // month 1-12 - formatters_.push_back(details::make_unique>(padding)); - need_localtime_ = true; - break; + case ('m'): // month 1-12 + formatters_.push_back(details::make_unique>(padding)); + need_localtime_ = true; + break; - case ('d'): // day of month 1-31 - formatters_.push_back(details::make_unique>(padding)); - need_localtime_ = true; - break; + case ('d'): // day of month 1-31 + formatters_.push_back(details::make_unique>(padding)); + need_localtime_ = true; + break; - case ('H'): // hours 24 - formatters_.push_back(details::make_unique>(padding)); - need_localtime_ = true; - break; + case ('H'): // hours 24 + formatters_.push_back(details::make_unique>(padding)); + need_localtime_ = true; + break; - case ('I'): // hours 12 - formatters_.push_back(details::make_unique>(padding)); - need_localtime_ = true; - break; + case ('I'): // hours 12 + formatters_.push_back(details::make_unique>(padding)); + need_localtime_ = true; + break; - case ('M'): // minutes - formatters_.push_back(details::make_unique>(padding)); - need_localtime_ = true; - break; + case ('M'): // minutes + formatters_.push_back(details::make_unique>(padding)); + need_localtime_ = true; + break; - case ('S'): // seconds - formatters_.push_back(details::make_unique>(padding)); - need_localtime_ = true; - break; + case ('S'): // seconds + formatters_.push_back(details::make_unique>(padding)); + need_localtime_ = true; + break; - case ('e'): // milliseconds - formatters_.push_back(details::make_unique>(padding)); - break; + case ('e'): // milliseconds + formatters_.push_back(details::make_unique>(padding)); + break; - case ('f'): // microseconds - formatters_.push_back(details::make_unique>(padding)); - break; + case ('f'): // microseconds + formatters_.push_back(details::make_unique>(padding)); + break; - case ('F'): // nanoseconds - formatters_.push_back(details::make_unique>(padding)); - break; + case ('F'): // nanoseconds + formatters_.push_back(details::make_unique>(padding)); + break; - case ('E'): // seconds since epoch - formatters_.push_back(details::make_unique>(padding)); - break; + case ('E'): // seconds since epoch + formatters_.push_back(details::make_unique>(padding)); + break; - case ('p'): // am/pm - formatters_.push_back(details::make_unique>(padding)); - need_localtime_ = true; - break; + case ('p'): // am/pm + formatters_.push_back(details::make_unique>(padding)); + need_localtime_ = true; + break; - case ('r'): // 12 hour clock 02:55:02 pm - formatters_.push_back(details::make_unique>(padding)); - need_localtime_ = true; - break; + case ('r'): // 12 hour clock 02:55:02 pm + formatters_.push_back(details::make_unique>(padding)); + need_localtime_ = true; + break; - case ('R'): // 24-hour HH:MM time - formatters_.push_back(details::make_unique>(padding)); - need_localtime_ = true; - break; + case ('R'): // 24-hour HH:MM time + formatters_.push_back(details::make_unique>(padding)); + need_localtime_ = true; + break; - case ('T'): - case ('X'): // ISO 8601 time format (HH:MM:SS) - formatters_.push_back(details::make_unique>(padding)); - need_localtime_ = true; - break; + case ('T'): + case ('X'): // ISO 8601 time format (HH:MM:SS) + formatters_.push_back(details::make_unique>(padding)); + need_localtime_ = true; + break; - case ('z'): // timezone - formatters_.push_back(details::make_unique>(padding)); - need_localtime_ = true; - break; + case ('z'): // timezone + formatters_.push_back(details::make_unique>(padding)); + need_localtime_ = true; + break; - case ('P'): // pid - formatters_.push_back(details::make_unique>(padding)); - break; + case ('P'): // pid + formatters_.push_back(details::make_unique>(padding)); + break; - case ('^'): // color range start - formatters_.push_back(details::make_unique(padding)); - break; + case ('^'): // color range start + formatters_.push_back(details::make_unique(padding)); + break; - case ('$'): // color range end - formatters_.push_back(details::make_unique(padding)); - break; + case ('$'): // color range end + formatters_.push_back(details::make_unique(padding)); + break; - case ('@'): // source location (filename:filenumber) - formatters_.push_back( - details::make_unique>(padding)); - break; + case ('@'): // source location (filename:filenumber) + formatters_.push_back( + details::make_unique>(padding)); + break; - case ('s'): // short source filename - without directory name - formatters_.push_back( - details::make_unique>(padding)); - break; + case ('s'): // short source filename - without directory name + formatters_.push_back( + details::make_unique>(padding)); + break; - case ('g'): // full source filename - formatters_.push_back( - details::make_unique>(padding)); - break; + case ('g'): // full source filename + formatters_.push_back( + details::make_unique>(padding)); + break; - case ('#'): // source line number - formatters_.push_back( - details::make_unique>(padding)); - break; + case ('#'): // source line number + formatters_.push_back( + details::make_unique>(padding)); + break; - case ('!'): // source funcname - formatters_.push_back( - details::make_unique>(padding)); - break; - - case ('%'): // % char - formatters_.push_back(details::make_unique('%')); - break; - - case ('u'): // elapsed time since last log message in nanos - formatters_.push_back( - details::make_unique>( - padding)); - break; - - case ('i'): // elapsed time since last log message in micros - formatters_.push_back( - details::make_unique>( - padding)); - break; - - case ('o'): // elapsed time since last log message in millis - formatters_.push_back( - details::make_unique>( - padding)); - break; - - case ('O'): // elapsed time since last log message in seconds - formatters_.push_back( - details::make_unique>( - padding)); - break; - - default: // Unknown flag appears as is - auto unknown_flag = details::make_unique(); - - if (!padding.truncate_) { - unknown_flag->add_ch('%'); - unknown_flag->add_ch(flag); - formatters_.push_back((std::move(unknown_flag))); - } - // fix issue #1617 (prev char was '!' and should have been treated as funcname flag instead - // of truncating flag) spdlog::set_pattern("[%10!] %v") => "[ main] some message" - // spdlog::set_pattern("[%3!!] %v") => "[mai] some message" - else { - padding.truncate_ = false; + case ('!'): // source funcname formatters_.push_back( details::make_unique>(padding)); - unknown_flag->add_ch(flag); - formatters_.push_back((std::move(unknown_flag))); - } + break; - break; + case ('%'): // % char + formatters_.push_back(details::make_unique('%')); + break; + + case ('u'): // elapsed time since last log message in nanos + formatters_.push_back( + details::make_unique>( + padding)); + break; + + case ('i'): // elapsed time since last log message in micros + formatters_.push_back( + details::make_unique>( + padding)); + break; + + case ('o'): // elapsed time since last log message in millis + formatters_.push_back( + details::make_unique>( + padding)); + break; + + case ('O'): // elapsed time since last log message in seconds + formatters_.push_back( + details::make_unique>( + padding)); + break; + + default: // Unknown flag appears as is + auto unknown_flag = details::make_unique(); + + if (!padding.truncate_) { + unknown_flag->add_ch('%'); + unknown_flag->add_ch(flag); + formatters_.push_back((std::move(unknown_flag))); + } + // fix issue #1617 (prev char was '!' and should have been treated as funcname flag + // instead of truncating flag) spdlog::set_pattern("[%10!] %v") => "[ main] some + // message" spdlog::set_pattern("[%3!!] %v") => "[mai] some message" + else { + padding.truncate_ = false; + formatters_.push_back( + details::make_unique>(padding)); + unknown_flag->add_ch(flag); + formatters_.push_back((std::move(unknown_flag))); + } + + break; } } // Extract given pad spec (e.g. %8X, %=8X, %-8!X, %8!X, %=8!X, %-8!X, %+8!X) // Advance the given it pass the end of the padding spec found (if any) // Return padding. -SPDLOG_INLINE details::padding_info -pattern_formatter::handle_padspec_(std::string::const_iterator &it, - std::string::const_iterator end) { +SPDLOG_INLINE details::padding_info pattern_formatter::handle_padspec_( + std::string::const_iterator &it, std::string::const_iterator end) { using details::padding_info; using details::scoped_padder; const size_t max_width = 64; @@ -1197,21 +1196,21 @@ pattern_formatter::handle_padspec_(std::string::const_iterator &it, padding_info::pad_side side; switch (*it) { - case '-': - side = padding_info::pad_side::right; - ++it; - break; - case '=': - side = padding_info::pad_side::center; - ++it; - break; - default: - side = details::padding_info::pad_side::left; - break; + case '-': + side = padding_info::pad_side::right; + ++it; + break; + case '=': + side = padding_info::pad_side::center; + ++it; + break; + default: + side = details::padding_info::pad_side::left; + break; } if (it == end || !std::isdigit(static_cast(*it))) { - return padding_info{}; // no padding if no digit found here + return padding_info{}; // no padding if no digit found here } auto width = static_cast(*it) - '0'; @@ -1237,7 +1236,7 @@ SPDLOG_INLINE void pattern_formatter::compile_pattern_(const std::string &patter formatters_.clear(); for (auto it = pattern.begin(); it != end; ++it) { if (*it == '%') { - if (user_chars) // append user chars found so far + if (user_chars) // append user chars found so far { formatters_.push_back(std::move(user_chars)); } @@ -1253,7 +1252,7 @@ SPDLOG_INLINE void pattern_formatter::compile_pattern_(const std::string &patter } else { break; } - } else // chars not following the % sign should be displayed as is + } else // chars not following the % sign should be displayed as is { if (!user_chars) { user_chars = details::make_unique(); @@ -1261,9 +1260,9 @@ SPDLOG_INLINE void pattern_formatter::compile_pattern_(const std::string &patter user_chars->add_ch(*it); } } - if (user_chars) // append raw chars found so far + if (user_chars) // append raw chars found so far { formatters_.push_back(std::move(user_chars)); } } -} // namespace spdlog +} // namespace spdlog diff --git a/include/spdlog/pattern_formatter.h b/include/spdlog/pattern_formatter.h index feceb891..ececd673 100644 --- a/include/spdlog/pattern_formatter.h +++ b/include/spdlog/pattern_formatter.h @@ -43,14 +43,15 @@ public: : padinfo_(padinfo) {} flag_formatter() = default; virtual ~flag_formatter() = default; - virtual void - format(const details::log_msg &msg, const std::tm &tm_time, memory_buf_t &dest) = 0; + virtual void format(const details::log_msg &msg, + const std::tm &tm_time, + memory_buf_t &dest) = 0; protected: padding_info padinfo_; }; -} // namespace details +} // namespace details class SPDLOG_API custom_flag_formatter : public details::flag_formatter { public: @@ -110,7 +111,7 @@ private: void compile_pattern_(const std::string &pattern); }; -} // namespace spdlog +} // namespace spdlog #ifdef SPDLOG_HEADER_ONLY #include "pattern_formatter-inl.h" diff --git a/include/spdlog/sinks/android_sink.h b/include/spdlog/sinks/android_sink.h index b5245515..4435a560 100644 --- a/include/spdlog/sinks/android_sink.h +++ b/include/spdlog/sinks/android_sink.h @@ -52,7 +52,7 @@ protected: // See system/core/liblog/logger_write.c for explanation of return value int ret = android_log(priority, tag_.c_str(), msg_output); if (ret == -EPERM) { - return; // !__android_log_is_loggable + return; // !__android_log_is_loggable } int retry_count = 0; while ((ret == -11 /*EAGAIN*/) && (retry_count < SPDLOG_ANDROID_RETRIES)) { @@ -74,33 +74,33 @@ private: // __android_log_buf_write, if user explicitly provides a non-default log buffer. Otherwise, // when using the default log buffer, always log via __android_log_write. template - typename std::enable_if(log_id::LOG_ID_MAIN), int>::type - android_log(int prio, const char *tag, const char *text) { + typename std::enable_if(log_id::LOG_ID_MAIN), int>::type android_log( + int prio, const char *tag, const char *text) { return __android_log_write(prio, tag, text); } template - typename std::enable_if(log_id::LOG_ID_MAIN), int>::type - android_log(int prio, const char *tag, const char *text) { + typename std::enable_if(log_id::LOG_ID_MAIN), int>::type android_log( + int prio, const char *tag, const char *text) { return __android_log_buf_write(ID, prio, tag, text); } static android_LogPriority convert_to_android_(spdlog::level::level_enum level) { switch (level) { - case spdlog::level::trace: - return ANDROID_LOG_VERBOSE; - case spdlog::level::debug: - return ANDROID_LOG_DEBUG; - case spdlog::level::info: - return ANDROID_LOG_INFO; - case spdlog::level::warn: - return ANDROID_LOG_WARN; - case spdlog::level::err: - return ANDROID_LOG_ERROR; - case spdlog::level::critical: - return ANDROID_LOG_FATAL; - default: - return ANDROID_LOG_DEFAULT; + case spdlog::level::trace: + return ANDROID_LOG_VERBOSE; + case spdlog::level::debug: + return ANDROID_LOG_DEBUG; + case spdlog::level::info: + return ANDROID_LOG_INFO; + case spdlog::level::warn: + return ANDROID_LOG_WARN; + case spdlog::level::err: + return ANDROID_LOG_ERROR; + case spdlog::level::critical: + return ANDROID_LOG_FATAL; + default: + return ANDROID_LOG_DEFAULT; } } @@ -116,7 +116,7 @@ using android_sink_buf_mt = android_sink; template using android_sink_buf_st = android_sink; -} // namespace sinks +} // namespace sinks // Create and register android syslog logger @@ -132,6 +132,6 @@ inline std::shared_ptr android_logger_st(const std::string &logger_name, return Factory::template create(logger_name, tag); } -} // namespace spdlog +} // namespace spdlog -#endif // __ANDROID__ +#endif // __ANDROID__ diff --git a/include/spdlog/sinks/ansicolor_sink-inl.h b/include/spdlog/sinks/ansicolor_sink-inl.h index 8a94f818..2194f67b 100644 --- a/include/spdlog/sinks/ansicolor_sink-inl.h +++ b/include/spdlog/sinks/ansicolor_sink-inl.h @@ -55,7 +55,7 @@ SPDLOG_INLINE void ansicolor_sink::log(const details::log_msg &msg print_ccode_(reset); // after color range print_range_(formatted, msg.color_range_end, formatted.size()); - } else // no color + } else // no color { print_range_(formatted, 0, formatted.size()); } @@ -75,8 +75,8 @@ SPDLOG_INLINE void ansicolor_sink::set_pattern(const std::string & } template -SPDLOG_INLINE void -ansicolor_sink::set_formatter(std::unique_ptr sink_formatter) { +SPDLOG_INLINE void ansicolor_sink::set_formatter( + std::unique_ptr sink_formatter) { std::lock_guard lock(mutex_); formatter_ = std::move(sink_formatter); } @@ -89,18 +89,18 @@ SPDLOG_INLINE bool ansicolor_sink::should_color() { template SPDLOG_INLINE void ansicolor_sink::set_color_mode(color_mode mode) { switch (mode) { - case color_mode::always: - should_do_colors_ = true; - return; - case color_mode::automatic: - should_do_colors_ = - details::os::in_terminal(target_file_) && details::os::is_color_terminal(); - return; - case color_mode::never: - should_do_colors_ = false; - return; - default: - should_do_colors_ = false; + case color_mode::always: + should_do_colors_ = true; + return; + case color_mode::automatic: + should_do_colors_ = + details::os::in_terminal(target_file_) && details::os::is_color_terminal(); + return; + case color_mode::never: + should_do_colors_ = false; + return; + default: + should_do_colors_ = false; } } @@ -131,5 +131,5 @@ template SPDLOG_INLINE ansicolor_stderr_sink::ansicolor_stderr_sink(color_mode mode) : ansicolor_sink(stderr, mode) {} -} // namespace sinks -} // namespace spdlog +} // namespace sinks +} // namespace spdlog diff --git a/include/spdlog/sinks/ansicolor_sink.h b/include/spdlog/sinks/ansicolor_sink.h index 8ef4c4bf..ff53730c 100644 --- a/include/spdlog/sinks/ansicolor_sink.h +++ b/include/spdlog/sinks/ansicolor_sink.h @@ -107,8 +107,8 @@ using ansicolor_stdout_sink_st = ansicolor_stdout_sink; using ansicolor_stderr_sink_st = ansicolor_stderr_sink; -} // namespace sinks -} // namespace spdlog +} // namespace sinks +} // namespace spdlog #ifdef SPDLOG_HEADER_ONLY #include "ansicolor_sink-inl.h" diff --git a/include/spdlog/sinks/base_sink-inl.h b/include/spdlog/sinks/base_sink-inl.h index 4008312e..ada161bc 100644 --- a/include/spdlog/sinks/base_sink-inl.h +++ b/include/spdlog/sinks/base_sink-inl.h @@ -18,8 +18,8 @@ SPDLOG_INLINE spdlog::sinks::base_sink::base_sink() : formatter_{details::make_unique()} {} template -SPDLOG_INLINE -spdlog::sinks::base_sink::base_sink(std::unique_ptr formatter) +SPDLOG_INLINE spdlog::sinks::base_sink::base_sink( + std::unique_ptr formatter) : formatter_{std::move(formatter)} {} template diff --git a/include/spdlog/sinks/base_sink.h b/include/spdlog/sinks/base_sink.h index 09f8b426..1ca772a6 100644 --- a/include/spdlog/sinks/base_sink.h +++ b/include/spdlog/sinks/base_sink.h @@ -43,8 +43,8 @@ protected: virtual void set_pattern_(const std::string &pattern); virtual void set_formatter_(std::unique_ptr sink_formatter); }; -} // namespace sinks -} // namespace spdlog +} // namespace sinks +} // namespace spdlog #ifdef SPDLOG_HEADER_ONLY #include "base_sink-inl.h" diff --git a/include/spdlog/sinks/basic_file_sink-inl.h b/include/spdlog/sinks/basic_file_sink-inl.h index 8c75a1a5..f7c1abf7 100644 --- a/include/spdlog/sinks/basic_file_sink-inl.h +++ b/include/spdlog/sinks/basic_file_sink-inl.h @@ -38,5 +38,5 @@ SPDLOG_INLINE void basic_file_sink::flush_() { file_helper_.flush(); } -} // namespace sinks -} // namespace spdlog +} // namespace sinks +} // namespace spdlog diff --git a/include/spdlog/sinks/basic_file_sink.h b/include/spdlog/sinks/basic_file_sink.h index a440b29a..699caa14 100644 --- a/include/spdlog/sinks/basic_file_sink.h +++ b/include/spdlog/sinks/basic_file_sink.h @@ -35,7 +35,7 @@ private: using basic_file_sink_mt = basic_file_sink; using basic_file_sink_st = basic_file_sink; -} // namespace sinks +} // namespace sinks // // factory functions @@ -58,7 +58,7 @@ inline std::shared_ptr basic_logger_st(const std::string &logger_name, event_handlers); } -} // namespace spdlog +} // namespace spdlog #ifdef SPDLOG_HEADER_ONLY #include "basic_file_sink-inl.h" diff --git a/include/spdlog/sinks/callback_sink.h b/include/spdlog/sinks/callback_sink.h index 419f84cd..71668ef2 100644 --- a/include/spdlog/sinks/callback_sink.h +++ b/include/spdlog/sinks/callback_sink.h @@ -36,7 +36,7 @@ private: using callback_sink_mt = callback_sink; using callback_sink_st = callback_sink; -} // namespace sinks +} // namespace sinks // // factory functions @@ -53,4 +53,4 @@ inline std::shared_ptr callback_logger_st(const std::string &logger_name return Factory::template create(logger_name, callback); } -} // namespace spdlog +} // namespace spdlog diff --git a/include/spdlog/sinks/daily_file_sink.h b/include/spdlog/sinks/daily_file_sink.h index 96c0fad8..1b1dc44a 100644 --- a/include/spdlog/sinks/daily_file_sink.h +++ b/include/spdlog/sinks/daily_file_sink.h @@ -195,7 +195,7 @@ using daily_file_format_sink_mt = daily_file_sink; -} // namespace sinks +} // namespace sinks // // factory functions @@ -213,14 +213,14 @@ inline std::shared_ptr daily_logger_mt(const std::string &logger_name, } template -inline std::shared_ptr -daily_logger_format_mt(const std::string &logger_name, - const filename_t &filename, - int hour = 0, - int minute = 0, - bool truncate = false, - uint16_t max_files = 0, - const file_event_handlers &event_handlers = {}) { +inline std::shared_ptr daily_logger_format_mt( + const std::string &logger_name, + const filename_t &filename, + int hour = 0, + int minute = 0, + bool truncate = false, + uint16_t max_files = 0, + const file_event_handlers &event_handlers = {}) { return Factory::template create( logger_name, filename, hour, minute, truncate, max_files, event_handlers); } @@ -238,15 +238,15 @@ inline std::shared_ptr daily_logger_st(const std::string &logger_name, } template -inline std::shared_ptr -daily_logger_format_st(const std::string &logger_name, - const filename_t &filename, - int hour = 0, - int minute = 0, - bool truncate = false, - uint16_t max_files = 0, - const file_event_handlers &event_handlers = {}) { +inline std::shared_ptr daily_logger_format_st( + const std::string &logger_name, + const filename_t &filename, + int hour = 0, + int minute = 0, + bool truncate = false, + uint16_t max_files = 0, + const file_event_handlers &event_handlers = {}) { return Factory::template create( logger_name, filename, hour, minute, truncate, max_files, event_handlers); } -} // namespace spdlog +} // namespace spdlog diff --git a/include/spdlog/sinks/dist_sink.h b/include/spdlog/sinks/dist_sink.h index 1a540463..69c4971c 100644 --- a/include/spdlog/sinks/dist_sink.h +++ b/include/spdlog/sinks/dist_sink.h @@ -77,5 +77,5 @@ protected: using dist_sink_mt = dist_sink; using dist_sink_st = dist_sink; -} // namespace sinks -} // namespace spdlog +} // namespace sinks +} // namespace spdlog diff --git a/include/spdlog/sinks/dup_filter_sink.h b/include/spdlog/sinks/dup_filter_sink.h index 21e4b115..1498142c 100644 --- a/include/spdlog/sinks/dup_filter_sink.h +++ b/include/spdlog/sinks/dup_filter_sink.h @@ -88,5 +88,5 @@ protected: using dup_filter_sink_mt = dup_filter_sink; using dup_filter_sink_st = dup_filter_sink; -} // namespace sinks -} // namespace spdlog +} // namespace sinks +} // namespace spdlog diff --git a/include/spdlog/sinks/hourly_file_sink.h b/include/spdlog/sinks/hourly_file_sink.h index 230d0d61..1f138925 100644 --- a/include/spdlog/sinks/hourly_file_sink.h +++ b/include/spdlog/sinks/hourly_file_sink.h @@ -164,7 +164,7 @@ private: using hourly_file_sink_mt = hourly_file_sink; using hourly_file_sink_st = hourly_file_sink; -} // namespace sinks +} // namespace sinks // // factory functions @@ -188,4 +188,4 @@ inline std::shared_ptr hourly_logger_st(const std::string &logger_name, return Factory::template create(logger_name, filename, truncate, max_files, event_handlers); } -} // namespace spdlog +} // namespace spdlog diff --git a/include/spdlog/sinks/kafka_sink.h b/include/spdlog/sinks/kafka_sink.h index d589449a..91e98786 100644 --- a/include/spdlog/sinks/kafka_sink.h +++ b/include/spdlog/sinks/kafka_sink.h @@ -90,7 +90,7 @@ private: using kafka_sink_mt = kafka_sink; using kafka_sink_st = kafka_sink; -} // namespace sinks +} // namespace sinks template inline std::shared_ptr kafka_logger_mt(const std::string &logger_name, @@ -105,15 +105,15 @@ inline std::shared_ptr kafka_logger_st(const std::string &logger_name, } template -inline std::shared_ptr -kafka_logger_async_mt(std::string logger_name, spdlog::sinks::kafka_sink_config config) { +inline std::shared_ptr kafka_logger_async_mt( + std::string logger_name, spdlog::sinks::kafka_sink_config config) { return Factory::template create(logger_name, config); } template -inline std::shared_ptr -kafka_logger_async_st(std::string logger_name, spdlog::sinks::kafka_sink_config config) { +inline std::shared_ptr kafka_logger_async_st( + std::string logger_name, spdlog::sinks::kafka_sink_config config) { return Factory::template create(logger_name, config); } -} // namespace spdlog +} // namespace spdlog diff --git a/include/spdlog/sinks/mongo_sink.h b/include/spdlog/sinks/mongo_sink.h index f3327485..c5b38ab9 100644 --- a/include/spdlog/sinks/mongo_sink.h +++ b/include/spdlog/sinks/mongo_sink.h @@ -83,26 +83,26 @@ private: using mongo_sink_mt = mongo_sink; using mongo_sink_st = mongo_sink; -} // namespace sinks +} // namespace sinks template -inline std::shared_ptr -mongo_logger_mt(const std::string &logger_name, - const std::string &db_name, - const std::string &collection_name, - const std::string &uri = "mongodb://localhost:27017") { +inline std::shared_ptr mongo_logger_mt( + const std::string &logger_name, + const std::string &db_name, + const std::string &collection_name, + const std::string &uri = "mongodb://localhost:27017") { return Factory::template create(logger_name, db_name, collection_name, uri); } template -inline std::shared_ptr -mongo_logger_st(const std::string &logger_name, - const std::string &db_name, - const std::string &collection_name, - const std::string &uri = "mongodb://localhost:27017") { +inline std::shared_ptr mongo_logger_st( + const std::string &logger_name, + const std::string &db_name, + const std::string &collection_name, + const std::string &uri = "mongodb://localhost:27017") { return Factory::template create(logger_name, db_name, collection_name, uri); } -} // namespace spdlog +} // namespace spdlog diff --git a/include/spdlog/sinks/msvc_sink.h b/include/spdlog/sinks/msvc_sink.h index 035d1e05..2e5f6875 100644 --- a/include/spdlog/sinks/msvc_sink.h +++ b/include/spdlog/sinks/msvc_sink.h @@ -41,7 +41,7 @@ protected: } memory_buf_t formatted; base_sink::formatter_->format(msg, formatted); - formatted.push_back('\0'); // add a null terminator for OutputDebugString + formatted.push_back('\0'); // add a null terminator for OutputDebugString #if defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT) wmemory_buf_t wformatted; details::os::utf8_to_wstrbuf(string_view_t(formatted.data(), formatted.size()), wformatted); @@ -62,7 +62,7 @@ using msvc_sink_st = msvc_sink; using windebug_sink_mt = msvc_sink_mt; using windebug_sink_st = msvc_sink_st; -} // namespace sinks -} // namespace spdlog +} // namespace sinks +} // namespace spdlog #endif diff --git a/include/spdlog/sinks/null_sink.h b/include/spdlog/sinks/null_sink.h index 31d7b452..c51247fe 100644 --- a/include/spdlog/sinks/null_sink.h +++ b/include/spdlog/sinks/null_sink.h @@ -22,7 +22,7 @@ protected: using null_sink_mt = null_sink; using null_sink_st = null_sink; -} // namespace sinks +} // namespace sinks template inline std::shared_ptr null_logger_mt(const std::string &logger_name) { @@ -38,4 +38,4 @@ inline std::shared_ptr null_logger_st(const std::string &logger_name) { return null_logger; } -} // namespace spdlog +} // namespace spdlog diff --git a/include/spdlog/sinks/ostream_sink.h b/include/spdlog/sinks/ostream_sink.h index 46eadb5f..6af9dd09 100644 --- a/include/spdlog/sinks/ostream_sink.h +++ b/include/spdlog/sinks/ostream_sink.h @@ -39,5 +39,5 @@ protected: using ostream_sink_mt = ostream_sink; using ostream_sink_st = ostream_sink; -} // namespace sinks -} // namespace spdlog +} // namespace sinks +} // namespace spdlog diff --git a/include/spdlog/sinks/qt_sinks.h b/include/spdlog/sinks/qt_sinks.h index 6423a8bc..87a962d3 100644 --- a/include/spdlog/sinks/qt_sinks.h +++ b/include/spdlog/sinks/qt_sinks.h @@ -167,13 +167,13 @@ protected: payload = QString::fromLatin1(str.data(), static_cast(str.size())); } - invoke_params params{max_lines_, // max lines - qt_text_edit_, // text edit to append to - std::move(payload), // text to append - default_color_, // default color - colors_.at(msg.level), // color to apply - color_range_start, // color range start - color_range_end}; // color range end + invoke_params params{max_lines_, // max lines + qt_text_edit_, // text edit to append to + std::move(payload), // text to append + default_color_, // default color + colors_.at(msg.level), // color to apply + color_range_start, // color range start + color_range_end}; // color range end QMetaObject::invokeMethod( qt_text_edit_, [params]() { invoke_method_(params); }, Qt::AutoConnection); @@ -193,7 +193,7 @@ protected: while (document->blockCount() > params.max_lines) { cursor.select(QTextCursor::BlockUnderCursor); cursor.removeSelectedText(); - cursor.deleteChar(); // delete the newline after the block + cursor.deleteChar(); // delete the newline after the block } cursor.movePosition(QTextCursor::End); @@ -232,7 +232,7 @@ using qt_sink_mt = qt_sink; using qt_sink_st = qt_sink; using qt_color_sink_mt = qt_color_sink; using qt_color_sink_st = qt_color_sink; -} // namespace sinks +} // namespace sinks // // Factory functions @@ -269,14 +269,16 @@ inline std::shared_ptr qt_logger_st(const std::string &logger_name, } // log to QObject template -inline std::shared_ptr -qt_logger_mt(const std::string &logger_name, QObject *qt_object, const std::string &meta_method) { +inline std::shared_ptr qt_logger_mt(const std::string &logger_name, + QObject *qt_object, + const std::string &meta_method) { return Factory::template create(logger_name, qt_object, meta_method); } template -inline std::shared_ptr -qt_logger_st(const std::string &logger_name, QObject *qt_object, const std::string &meta_method) { +inline std::shared_ptr qt_logger_st(const std::string &logger_name, + QObject *qt_object, + const std::string &meta_method) { return Factory::template create(logger_name, qt_object, meta_method); } @@ -299,4 +301,4 @@ inline std::shared_ptr qt_color_logger_st(const std::string &logger_name false, is_utf8); } -} // namespace spdlog +} // namespace spdlog diff --git a/include/spdlog/sinks/ringbuffer_sink.h b/include/spdlog/sinks/ringbuffer_sink.h index 824c4475..6156c6a5 100644 --- a/include/spdlog/sinks/ringbuffer_sink.h +++ b/include/spdlog/sinks/ringbuffer_sink.h @@ -62,6 +62,6 @@ private: using ringbuffer_sink_mt = ringbuffer_sink; using ringbuffer_sink_st = ringbuffer_sink; -} // namespace sinks +} // namespace sinks -} // namespace spdlog +} // namespace spdlog diff --git a/include/spdlog/sinks/rotating_file_sink-inl.h b/include/spdlog/sinks/rotating_file_sink-inl.h index f6f3b52e..6f10256f 100644 --- a/include/spdlog/sinks/rotating_file_sink-inl.h +++ b/include/spdlog/sinks/rotating_file_sink-inl.h @@ -24,12 +24,12 @@ namespace spdlog { namespace sinks { template -SPDLOG_INLINE -rotating_file_sink::rotating_file_sink(filename_t base_filename, - std::size_t max_size, - std::size_t max_files, - bool rotate_on_open, - const file_event_handlers &event_handlers) +SPDLOG_INLINE rotating_file_sink::rotating_file_sink( + filename_t base_filename, + std::size_t max_size, + std::size_t max_files, + bool rotate_on_open, + const file_event_handlers &event_handlers) : base_filename_(std::move(base_filename)), max_size_(max_size), max_files_(max_files), @@ -42,7 +42,7 @@ rotating_file_sink::rotating_file_sink(filename_t base_filename, throw_spdlog_ex("rotating sink constructor: max_files arg cannot exceed 200000"); } file_helper_.open(calc_filename(base_filename_, 0)); - current_size_ = file_helper_.size(); // expensive. called only once + current_size_ = file_helper_.size(); // expensive. called only once if (rotate_on_open && current_size_ > 0) { rotate_(); current_size_ = 0; @@ -119,7 +119,7 @@ SPDLOG_INLINE void rotating_file_sink::rotate_() { details::os::sleep_for_millis(100); if (!rename_file_(src, target)) { file_helper_.reopen( - true); // truncate the log file anyway to prevent it to grow beyond its limit! + true); // truncate the log file anyway to prevent it to grow beyond its limit! current_size_ = 0; throw_spdlog_ex("rotating_file_sink: failed renaming " + filename_to_str(src) + " to " + filename_to_str(target), @@ -140,5 +140,5 @@ SPDLOG_INLINE bool rotating_file_sink::rename_file_(const filename_t &src return details::os::rename(src_filename, target_filename) == 0; } -} // namespace sinks -} // namespace spdlog +} // namespace sinks +} // namespace spdlog diff --git a/include/spdlog/sinks/rotating_file_sink.h b/include/spdlog/sinks/rotating_file_sink.h index 068eaf33..cd43d349 100644 --- a/include/spdlog/sinks/rotating_file_sink.h +++ b/include/spdlog/sinks/rotating_file_sink.h @@ -55,7 +55,7 @@ private: using rotating_file_sink_mt = rotating_file_sink; using rotating_file_sink_st = rotating_file_sink; -} // namespace sinks +} // namespace sinks // // factory functions @@ -82,7 +82,7 @@ inline std::shared_ptr rotating_logger_st(const std::string &logger_name return Factory::template create( logger_name, filename, max_file_size, max_files, rotate_on_open, event_handlers); } -} // namespace spdlog +} // namespace spdlog #ifdef SPDLOG_HEADER_ONLY #include "rotating_file_sink-inl.h" diff --git a/include/spdlog/sinks/sink.h b/include/spdlog/sinks/sink.h index fe72e6cd..58506853 100644 --- a/include/spdlog/sinks/sink.h +++ b/include/spdlog/sinks/sink.h @@ -26,8 +26,8 @@ protected: level_t level_{level::trace}; }; -} // namespace sinks -} // namespace spdlog +} // namespace sinks +} // namespace spdlog #ifdef SPDLOG_HEADER_ONLY #include "sink-inl.h" diff --git a/include/spdlog/sinks/stdout_color_sinks-inl.h b/include/spdlog/sinks/stdout_color_sinks-inl.h index d0cf8d63..166e3861 100644 --- a/include/spdlog/sinks/stdout_color_sinks-inl.h +++ b/include/spdlog/sinks/stdout_color_sinks-inl.h @@ -35,4 +35,4 @@ SPDLOG_INLINE std::shared_ptr stderr_color_st(const std::string &logger_ color_mode mode) { return Factory::template create(logger_name, mode); } -} // namespace spdlog +} // namespace spdlog diff --git a/include/spdlog/sinks/stdout_color_sinks.h b/include/spdlog/sinks/stdout_color_sinks.h index 77e3b45d..72991fe0 100644 --- a/include/spdlog/sinks/stdout_color_sinks.h +++ b/include/spdlog/sinks/stdout_color_sinks.h @@ -24,7 +24,7 @@ using stdout_color_sink_st = ansicolor_stdout_sink_st; using stderr_color_sink_mt = ansicolor_stderr_sink_mt; using stderr_color_sink_st = ansicolor_stderr_sink_st; #endif -} // namespace sinks +} // namespace sinks template std::shared_ptr stdout_color_mt(const std::string &logger_name, @@ -42,7 +42,7 @@ template std::shared_ptr stderr_color_st(const std::string &logger_name, color_mode mode = color_mode::automatic); -} // namespace spdlog +} // namespace spdlog #ifdef SPDLOG_HEADER_ONLY #include "stdout_color_sinks-inl.h" diff --git a/include/spdlog/sinks/stdout_sinks-inl.h b/include/spdlog/sinks/stdout_sinks-inl.h index e8b98b69..f98244db 100644 --- a/include/spdlog/sinks/stdout_sinks-inl.h +++ b/include/spdlog/sinks/stdout_sinks-inl.h @@ -16,13 +16,13 @@ // so instead we use ::FileWrite #include - #ifndef _USING_V110_SDK71_ // fileapi.h doesn't exist in winxp - #include // WriteFile (..) + #ifndef _USING_V110_SDK71_ // fileapi.h doesn't exist in winxp + #include // WriteFile (..) #endif - #include // _get_osfhandle(..) - #include // _fileno(..) -#endif // WIN32 + #include // _get_osfhandle(..) + #include // _fileno(..) +#endif // WIN32 namespace spdlog { @@ -44,7 +44,7 @@ SPDLOG_INLINE stdout_sink_base::stdout_sink_base(FILE *file) if (handle_ == INVALID_HANDLE_VALUE && file != stdout && file != stderr) { throw_spdlog_ex("spdlog::stdout_sink_base: _get_osfhandle() failed", errno); } -#endif // WIN32 +#endif // WIN32 } template @@ -68,8 +68,8 @@ SPDLOG_INLINE void stdout_sink_base::log(const details::log_msg &m memory_buf_t formatted; formatter_->format(msg, formatted); ::fwrite(formatted.data(), sizeof(char), formatted.size(), file_); -#endif // WIN32 - ::fflush(file_); // flush every line to terminal +#endif // WIN32 + ::fflush(file_); // flush every line to terminal } template @@ -85,8 +85,8 @@ SPDLOG_INLINE void stdout_sink_base::set_pattern(const std::string } template -SPDLOG_INLINE void -stdout_sink_base::set_formatter(std::unique_ptr sink_formatter) { +SPDLOG_INLINE void stdout_sink_base::set_formatter( + std::unique_ptr sink_formatter) { std::lock_guard lock(mutex_); formatter_ = std::move(sink_formatter); } @@ -101,7 +101,7 @@ template SPDLOG_INLINE stderr_sink::stderr_sink() : stdout_sink_base(stderr) {} -} // namespace sinks +} // namespace sinks // factory methods template @@ -123,4 +123,4 @@ template SPDLOG_INLINE std::shared_ptr stderr_logger_st(const std::string &logger_name) { return Factory::template create(logger_name); } -} // namespace spdlog +} // namespace spdlog diff --git a/include/spdlog/sinks/stdout_sinks.h b/include/spdlog/sinks/stdout_sinks.h index 864cac70..6ef09968 100644 --- a/include/spdlog/sinks/stdout_sinks.h +++ b/include/spdlog/sinks/stdout_sinks.h @@ -41,7 +41,7 @@ protected: std::unique_ptr formatter_; #ifdef _WIN32 HANDLE handle_; -#endif // WIN32 +#endif // WIN32 }; template @@ -62,7 +62,7 @@ using stdout_sink_st = stdout_sink; using stderr_sink_mt = stderr_sink; using stderr_sink_st = stderr_sink; -} // namespace sinks +} // namespace sinks // factory methods template @@ -77,7 +77,7 @@ std::shared_ptr stderr_logger_mt(const std::string &logger_name); template std::shared_ptr stderr_logger_st(const std::string &logger_name); -} // namespace spdlog +} // namespace spdlog #ifdef SPDLOG_HEADER_ONLY #include "stdout_sinks-inl.h" diff --git a/include/spdlog/sinks/syslog_sink.h b/include/spdlog/sinks/syslog_sink.h index 6f47076c..bfc16453 100644 --- a/include/spdlog/sinks/syslog_sink.h +++ b/include/spdlog/sinks/syslog_sink.h @@ -18,7 +18,6 @@ namespace sinks { */ template class syslog_sink : public base_sink { - public: syslog_sink(std::string ident, int syslog_option, int syslog_facility, bool enable_formatting) : enable_formatting_{enable_formatting}, @@ -79,7 +78,7 @@ private: using syslog_sink_mt = syslog_sink; using syslog_sink_st = syslog_sink; -} // namespace sinks +} // namespace sinks // Create and register a syslog logger template @@ -101,4 +100,4 @@ inline std::shared_ptr syslog_logger_st(const std::string &logger_name, return Factory::template create(logger_name, syslog_ident, syslog_option, syslog_facility, enable_formatting); } -} // namespace spdlog +} // namespace spdlog diff --git a/include/spdlog/sinks/systemd_sink.h b/include/spdlog/sinks/systemd_sink.h index aa0d1046..563834ad 100644 --- a/include/spdlog/sinks/systemd_sink.h +++ b/include/spdlog/sinks/systemd_sink.h @@ -102,7 +102,7 @@ protected: using systemd_sink_mt = systemd_sink; using systemd_sink_st = systemd_sink; -} // namespace sinks +} // namespace sinks // Create and register a syslog logger template @@ -118,4 +118,4 @@ inline std::shared_ptr systemd_logger_st(const std::string &logger_name, bool enable_formatting = false) { return Factory::template create(logger_name, ident, enable_formatting); } -} // namespace spdlog +} // namespace spdlog diff --git a/include/spdlog/sinks/tcp_sink.h b/include/spdlog/sinks/tcp_sink.h index 8ce4ff05..25349645 100644 --- a/include/spdlog/sinks/tcp_sink.h +++ b/include/spdlog/sinks/tcp_sink.h @@ -31,7 +31,7 @@ namespace sinks { struct tcp_sink_config { std::string server_host; int server_port; - bool lazy_connect = false; // if true connect on first log call instead of on construction + bool lazy_connect = false; // if true connect on first log call instead of on construction tcp_sink_config(std::string host, int port) : server_host{std::move(host)}, @@ -71,5 +71,5 @@ protected: using tcp_sink_mt = tcp_sink; using tcp_sink_st = tcp_sink; -} // namespace sinks -} // namespace spdlog +} // namespace sinks +} // namespace spdlog diff --git a/include/spdlog/sinks/udp_sink.h b/include/spdlog/sinks/udp_sink.h index d2c5351d..4bff0fd2 100644 --- a/include/spdlog/sinks/udp_sink.h +++ b/include/spdlog/sinks/udp_sink.h @@ -55,7 +55,7 @@ protected: using udp_sink_mt = udp_sink; using udp_sink_st = udp_sink; -} // namespace sinks +} // namespace sinks // // factory functions @@ -66,4 +66,4 @@ inline std::shared_ptr udp_logger_mt(const std::string &logger_name, return Factory::template create(logger_name, skin_config); } -} // namespace spdlog +} // namespace spdlog diff --git a/include/spdlog/sinks/win_eventlog_sink.h b/include/spdlog/sinks/win_eventlog_sink.h index 09f3aa38..2c9b582d 100644 --- a/include/spdlog/sinks/win_eventlog_sink.h +++ b/include/spdlog/sinks/win_eventlog_sink.h @@ -130,7 +130,7 @@ public: ~process_token_t() { ::CloseHandle(token_handle_); } } current_process_token( - ::GetCurrentProcess()); // GetCurrentProcess returns pseudohandle, no leak here! + ::GetCurrentProcess()); // GetCurrentProcess returns pseudohandle, no leak here! // Get the required size, this is expected to fail with ERROR_INSUFFICIENT_BUFFER and return // the token size @@ -155,30 +155,30 @@ public: struct eventlog { static WORD get_event_type(details::log_msg const &msg) { switch (msg.level) { - case level::trace: - case level::debug: - return EVENTLOG_SUCCESS; + case level::trace: + case level::debug: + return EVENTLOG_SUCCESS; - case level::info: - return EVENTLOG_INFORMATION_TYPE; + case level::info: + return EVENTLOG_INFORMATION_TYPE; - case level::warn: - return EVENTLOG_WARNING_TYPE; + case level::warn: + return EVENTLOG_WARNING_TYPE; - case level::err: - case level::critical: - case level::off: - return EVENTLOG_ERROR_TYPE; + case level::err: + case level::critical: + case level::off: + return EVENTLOG_ERROR_TYPE; - default: - return EVENTLOG_INFORMATION_TYPE; + default: + return EVENTLOG_INFORMATION_TYPE; } } static WORD get_event_category(details::log_msg const &msg) { return (WORD)msg.level; } }; -} // namespace internal +} // namespace internal /* * Windows Event Log sink @@ -247,15 +247,14 @@ public: } ~win_eventlog_sink() { - if (hEventLog_) - DeregisterEventSource(hEventLog_); + if (hEventLog_) DeregisterEventSource(hEventLog_); } }; -} // namespace win_eventlog +} // namespace win_eventlog using win_eventlog_sink_mt = win_eventlog::win_eventlog_sink; using win_eventlog_sink_st = win_eventlog::win_eventlog_sink; -} // namespace sinks -} // namespace spdlog +} // namespace sinks +} // namespace spdlog diff --git a/include/spdlog/sinks/wincolor_sink-inl.h b/include/spdlog/sinks/wincolor_sink-inl.h index 4db7c45e..10b8a74a 100644 --- a/include/spdlog/sinks/wincolor_sink-inl.h +++ b/include/spdlog/sinks/wincolor_sink-inl.h @@ -20,18 +20,17 @@ SPDLOG_INLINE wincolor_sink::wincolor_sink(void *out_handle, color : out_handle_(out_handle), mutex_(ConsoleMutex::mutex()), formatter_(details::make_unique()) { - set_color_mode_impl(mode); // set level colors - colors_[level::trace] = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; // white - colors_[level::debug] = FOREGROUND_GREEN | FOREGROUND_BLUE; // cyan - colors_[level::info] = FOREGROUND_GREEN; // green + colors_[level::trace] = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE; // white + colors_[level::debug] = FOREGROUND_GREEN | FOREGROUND_BLUE; // cyan + colors_[level::info] = FOREGROUND_GREEN; // green colors_[level::warn] = - FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY; // intense yellow - colors_[level::err] = FOREGROUND_RED | FOREGROUND_INTENSITY; // intense red + FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY; // intense yellow + colors_[level::err] = FOREGROUND_RED | FOREGROUND_INTENSITY; // intense red colors_[level::critical] = BACKGROUND_RED | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | - FOREGROUND_INTENSITY; // intense white on red background + FOREGROUND_INTENSITY; // intense white on red background colors_[level::off] = 0; } @@ -69,7 +68,7 @@ void SPDLOG_INLINE wincolor_sink::log(const details::log_msg &msg) // reset to orig colors ::SetConsoleTextAttribute(static_cast(out_handle_), orig_attribs); print_range_(formatted, msg.color_range_end, formatted.size()); - } else // print without colors if color range is invalid (or color is disabled) + } else // print without colors if color range is invalid (or color is disabled) { write_to_file_(formatted); } @@ -126,7 +125,7 @@ wincolor_sink::set_foreground_color_(std::uint16_t attribs) { auto ignored = ::SetConsoleTextAttribute(static_cast(out_handle_), static_cast(new_attribs)); (void)(ignored); - return static_cast(orig_buffer_info.wAttributes); // return orig attribs + return static_cast(orig_buffer_info.wAttributes); // return orig attribs } // print a range of formatted message to console @@ -160,5 +159,5 @@ SPDLOG_INLINE wincolor_stdout_sink::wincolor_stdout_sink(color_mod template SPDLOG_INLINE wincolor_stderr_sink::wincolor_stderr_sink(color_mode mode) : wincolor_sink(::GetStdHandle(STD_ERROR_HANDLE), mode) {} -} // namespace sinks -} // namespace spdlog +} // namespace sinks +} // namespace spdlog diff --git a/include/spdlog/sinks/wincolor_sink.h b/include/spdlog/sinks/wincolor_sink.h index 5de60b22..8ba594cc 100644 --- a/include/spdlog/sinks/wincolor_sink.h +++ b/include/spdlog/sinks/wincolor_sink.h @@ -74,8 +74,8 @@ using wincolor_stdout_sink_st = wincolor_stdout_sink using wincolor_stderr_sink_mt = wincolor_stderr_sink; using wincolor_stderr_sink_st = wincolor_stderr_sink; -} // namespace sinks -} // namespace spdlog +} // namespace sinks +} // namespace spdlog #ifdef SPDLOG_HEADER_ONLY #include "wincolor_sink-inl.h" diff --git a/include/spdlog/spdlog-inl.h b/include/spdlog/spdlog-inl.h index d6681407..97c36222 100644 --- a/include/spdlog/spdlog-inl.h +++ b/include/spdlog/spdlog-inl.h @@ -89,4 +89,4 @@ SPDLOG_INLINE void apply_logger_env_levels(std::shared_ptr logger) { details::registry::instance().apply_logger_env_levels(std::move(logger)); } -} // namespace spdlog +} // namespace spdlog diff --git a/include/spdlog/spdlog.h b/include/spdlog/spdlog.h index 0987b2d5..a8afbcec 100644 --- a/include/spdlog/spdlog.h +++ b/include/spdlog/spdlog.h @@ -141,8 +141,10 @@ SPDLOG_API void set_default_logger(std::shared_ptr default_logge SPDLOG_API void apply_logger_env_levels(std::shared_ptr logger); template -inline void -log(source_loc source, level::level_enum lvl, format_string_t fmt, Args &&...args) { +inline void log(source_loc source, + level::level_enum lvl, + format_string_t fmt, + Args &&...args) { default_logger_raw()->log(source, lvl, fmt, std::forward(args)...); } @@ -193,8 +195,10 @@ inline void log(level::level_enum lvl, const T &msg) { #ifdef SPDLOG_WCHAR_TO_UTF8_SUPPORT template -inline void -log(source_loc source, level::level_enum lvl, wformat_string_t fmt, Args &&...args) { +inline void log(source_loc source, + level::level_enum lvl, + wformat_string_t fmt, + Args &&...args) { default_logger_raw()->log(source, lvl, fmt, std::forward(args)...); } @@ -264,7 +268,7 @@ inline void critical(const T &msg) { default_logger_raw()->critical(msg); } -} // namespace spdlog +} // namespace spdlog // // enable/disable log calls at compile time according to global level. @@ -345,4 +349,4 @@ inline void critical(const T &msg) { #include "spdlog-inl.h" #endif -#endif // SPDLOG_H +#endif // SPDLOG_H diff --git a/include/spdlog/stopwatch.h b/include/spdlog/stopwatch.h index 3dc1693b..d19e591f 100644 --- a/include/spdlog/stopwatch.h +++ b/include/spdlog/stopwatch.h @@ -41,7 +41,7 @@ public: void reset() { start_tp_ = clock::now(); } }; -} // namespace spdlog +} // namespace spdlog // Support for fmt formatting (e.g. "{:012.9}" or just "{}") namespace @@ -59,4 +59,4 @@ struct formatter : formatter { return formatter::format(sw.elapsed().count(), ctx); } }; -} // namespace std +} // namespace std diff --git a/src/bundled_fmtlib_format.cpp b/src/bundled_fmtlib_format.cpp index ff149484..ef324688 100644 --- a/src/bundled_fmtlib_format.cpp +++ b/src/bundled_fmtlib_format.cpp @@ -31,8 +31,10 @@ template FMT_API void buffer::append(const char *, const char *); // DEPRECATED! // There is no correspondent extern template in format.h because of // incompatibility between clang and gcc (#2377). -template FMT_API void -vformat_to(buffer &, string_view, basic_format_args, locale_ref); +template FMT_API void vformat_to(buffer &, + string_view, + basic_format_args, + locale_ref); // Explicit instantiations for wchar_t. @@ -41,7 +43,7 @@ template FMT_API auto decimal_point_impl(locale_ref) -> wchar_t; template FMT_API void buffer::append(const wchar_t *, const wchar_t *); -} // namespace detail +} // namespace detail FMT_END_NAMESPACE -#endif // !SPDLOG_FMT_EXTERNAL +#endif // !SPDLOG_FMT_EXTERNAL diff --git a/src/color_sinks.cpp b/src/color_sinks.cpp index d0516b45..c44db197 100644 --- a/src/color_sinks.cpp +++ b/src/color_sinks.cpp @@ -45,11 +45,11 @@ template SPDLOG_API std::shared_ptr spdlog::stderr_color_st(const std::string &logger_name, color_mode mode); -template SPDLOG_API std::shared_ptr -spdlog::stdout_color_mt(const std::string &logger_name, color_mode mode); -template SPDLOG_API std::shared_ptr -spdlog::stdout_color_st(const std::string &logger_name, color_mode mode); -template SPDLOG_API std::shared_ptr -spdlog::stderr_color_mt(const std::string &logger_name, color_mode mode); -template SPDLOG_API std::shared_ptr -spdlog::stderr_color_st(const std::string &logger_name, color_mode mode); +template SPDLOG_API std::shared_ptr spdlog::stdout_color_mt( + const std::string &logger_name, color_mode mode); +template SPDLOG_API std::shared_ptr spdlog::stdout_color_st( + const std::string &logger_name, color_mode mode); +template SPDLOG_API std::shared_ptr spdlog::stderr_color_mt( + const std::string &logger_name, color_mode mode); +template SPDLOG_API std::shared_ptr spdlog::stderr_color_st( + const std::string &logger_name, color_mode mode); diff --git a/src/stdout_sinks.cpp b/src/stdout_sinks.cpp index df7b6490..bf4cfae2 100644 --- a/src/stdout_sinks.cpp +++ b/src/stdout_sinks.cpp @@ -27,11 +27,11 @@ spdlog::stderr_logger_mt(const std::string &logger_ template SPDLOG_API std::shared_ptr spdlog::stderr_logger_st(const std::string &logger_name); -template SPDLOG_API std::shared_ptr -spdlog::stdout_logger_mt(const std::string &logger_name); -template SPDLOG_API std::shared_ptr -spdlog::stdout_logger_st(const std::string &logger_name); -template SPDLOG_API std::shared_ptr -spdlog::stderr_logger_mt(const std::string &logger_name); -template SPDLOG_API std::shared_ptr -spdlog::stderr_logger_st(const std::string &logger_name); +template SPDLOG_API std::shared_ptr spdlog::stdout_logger_mt( + const std::string &logger_name); +template SPDLOG_API std::shared_ptr spdlog::stdout_logger_st( + const std::string &logger_name); +template SPDLOG_API std::shared_ptr spdlog::stderr_logger_mt( + const std::string &logger_name); +template SPDLOG_API std::shared_ptr spdlog::stderr_logger_st( + const std::string &logger_name); diff --git a/tests/includes.h b/tests/includes.h index 84e8bf91..8514d642 100644 --- a/tests/includes.h +++ b/tests/includes.h @@ -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 #if defined(__GNUC__) && __GNUC__ == 12 diff --git a/tests/main.cpp b/tests/main.cpp index fd562ad3..a4a4ff15 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -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 diff --git a/tests/test_async.cpp b/tests/test_async.cpp index 44d34ebe..76fdd7c6 100644 --- a/tests/test_async.cpp +++ b/tests/test_async.cpp @@ -94,7 +94,6 @@ TEST_CASE("flush", "[async]") { } TEST_CASE("async periodic flush", "[async]") { - auto logger = spdlog::create_async("as"); auto test_sink = std::static_pointer_cast(logger->sinks()[0]); diff --git a/tests/test_backtrace.cpp b/tests/test_backtrace.cpp index 93888214..4d78c0c2 100644 --- a/tests/test_backtrace.cpp +++ b/tests/test_backtrace.cpp @@ -3,7 +3,6 @@ #include "spdlog/async.h" TEST_CASE("bactrace1", "[bactrace]") { - using spdlog::sinks::test_sink_st; auto test_sink = std::make_shared(); 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"); diff --git a/tests/test_create_dir.cpp b/tests/test_create_dir.cpp index b53bebf1..f88825b0 100644 --- a/tests/test_create_dir.cpp +++ b/tests/test_create_dir.cpp @@ -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"), diff --git a/tests/test_daily_logger.cpp b/tests/test_daily_logger.cpp index 138e6120..fe4783cb 100644 --- a/tests/test_daily_logger.cpp +++ b/tests/test_daily_logger.cpp @@ -37,7 +37,6 @@ TEST_CASE("daily_logger with dateonly calculator", "[daily_logger]") { auto logger = spdlog::create("logger", basename, 0, 0); for (int i = 0; i < 10; ++i) { - logger->info("Test message {}", i); } logger->flush(); diff --git a/tests/test_dup_filter.cpp b/tests/test_dup_filter.cpp index 22623c2e..78e22be3 100644 --- a/tests/test_dup_filter.cpp +++ b/tests/test_dup_filter.cpp @@ -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.."); } diff --git a/tests/test_errors.cpp b/tests/test_errors.cpp index f985fd4e..7dde919d 100644 --- a/tests/test_errors.cpp +++ b/tests/test_errors.cpp @@ -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("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); diff --git a/tests/test_eventlog.cpp b/tests/test_eventlog.cpp index 45d7f58d..702eabea 100644 --- a/tests/test_eventlog.cpp +++ b/tests/test_eventlog.cpp @@ -72,4 +72,4 @@ TEST_CASE("eventlog", "[eventlog]") { "my critical message", EVENTLOG_ERROR_TYPE); } -#endif //_WIN32 +#endif //_WIN32 diff --git a/tests/test_file_logging.cpp b/tests/test_file_logging.cpp index 73c59599..ac378b5c 100644 --- a/tests/test_file_logging.cpp +++ b/tests/test_file_logging.cpp @@ -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); } diff --git a/tests/test_macros.cpp b/tests/test_macros.cpp index 37a2a916..132706f1 100644 --- a/tests/test_macros.cpp +++ b/tests/test_macros.cpp @@ -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); diff --git a/tests/test_misc.cpp b/tests/test_misc.cpp index 9f359e7f..367eeb75 100644 --- a/tests/test_misc.cpp +++ b/tests/test_misc.cpp @@ -3,7 +3,6 @@ template 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(oss); diff --git a/tests/test_mpmc_q.cpp b/tests/test_mpmc_q.cpp index 41b99a21..bc7a37d9 100644 --- a/tests/test_mpmc_q.cpp +++ b/tests/test_mpmc_q.cpp @@ -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 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 q(q_size); for (int i = 0; i < static_cast(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); diff --git a/tests/test_sink.h b/tests/test_sink.h index 9f5a9394..529d86dd 100644 --- a/tests/test_sink.h +++ b/tests/test_sink.h @@ -65,5 +65,5 @@ protected: using test_sink_mt = test_sink; using test_sink_st = test_sink; -} // namespace sinks -} // namespace spdlog +} // namespace sinks +} // namespace spdlog diff --git a/tests/test_time_point.cpp b/tests/test_time_point.cpp index c409bb24..b7b1b232 100644 --- a/tests/test_time_point.cpp +++ b/tests/test_time_point.cpp @@ -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 lines = test_sink->lines(); diff --git a/tests/utils.cpp b/tests/utils.cpp index cec29c42..1fa26175 100644 --- a/tests/utils.cpp +++ b/tests/utils.cpp @@ -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;