From 50648553cfb5c01775d32ca5bd19fe3e2fbd7a0c Mon Sep 17 00:00:00 2001 From: gabime Date: Wed, 21 Nov 2018 16:02:02 +0200 Subject: [PATCH] clang-format --- bench/formatter-bench.cpp | 29 +++++++++------------- include/spdlog/details/os.h | 1 - include/spdlog/details/pattern_formatter.h | 3 ++- include/spdlog/spdlog.h | 1 - 4 files changed, 14 insertions(+), 20 deletions(-) diff --git a/bench/formatter-bench.cpp b/bench/formatter-bench.cpp index e484041b..ccdc9fb1 100644 --- a/bench/formatter-bench.cpp +++ b/bench/formatter-bench.cpp @@ -21,18 +21,16 @@ void bench_scoped_pad(benchmark::State &state, size_t wrapped_size, spdlog::deta } } - void bench_formatter(benchmark::State &state, std::string pattern) { auto formatter = spdlog::details::make_unique(pattern); fmt::memory_buffer dest; std::string logger_name = "logger-name"; - const char* text = "Hello. This is some message with length of 80 "; - + const char *text = "Hello. This is some message with length of 80 "; spdlog::details::log_msg msg(&logger_name, spdlog::level::info, text); -// formatter->format(msg, dest); -// printf("%s\n", fmt::to_string(dest).c_str()); + // formatter->format(msg, dest); + // printf("%s\n", fmt::to_string(dest).c_str()); for (auto _ : state) { @@ -47,46 +45,43 @@ void bench_formatters() // basic patterns(single flag) std::string all_flags = "+vtPnlLaAbBcCYDmdHIMSefFprRTXzEi%"; std::vector basic_patterns; - for(auto &flag:all_flags) + for (auto &flag : all_flags) { auto pattern = std::string("%") + flag; benchmark::RegisterBenchmark(pattern.c_str(), bench_formatter, pattern); - //bench left padding + // bench left padding pattern = std::string("%16") + flag; benchmark::RegisterBenchmark(pattern.c_str(), bench_formatter, pattern); - //bench center padding + // bench center padding pattern = std::string("%=16") + flag; benchmark::RegisterBenchmark(pattern.c_str(), bench_formatter, pattern); } - // complex patterns std::vector patterns = { - "[%D %X] [%l] [%n] %v", - "[%Y-%m-%d %H:%M:%S.%e] [%l] [%n] %v", - "[%Y-%m-%d %H:%M:%S.%e] [%l] [%n] [%t] %v", + "[%D %X] [%l] [%n] %v", + "[%Y-%m-%d %H:%M:%S.%e] [%l] [%n] %v", + "[%Y-%m-%d %H:%M:%S.%e] [%l] [%n] [%t] %v", }; - for(auto &pattern:patterns) + for (auto &pattern : patterns) { benchmark::RegisterBenchmark(pattern.c_str(), bench_formatter, pattern)->Iterations(2500000); } } - int main(int argc, char *argv[]) { - if(argc > 1) //bench given pattern + if (argc > 1) // bench given pattern { std::string pattern = argv[1]; benchmark::RegisterBenchmark(pattern.c_str(), bench_formatter, pattern); } - else //bench all flags + else // bench all flags { bench_formatters(); } benchmark::Initialize(&argc, argv); benchmark::RunSpecifiedBenchmarks(); } - diff --git a/include/spdlog/details/os.h b/include/spdlog/details/os.h index 5e11da60..f2422904 100644 --- a/include/spdlog/details/os.h +++ b/include/spdlog/details/os.h @@ -383,7 +383,6 @@ inline int pid() #endif } - // Determine if the terminal supports colors // Source: https://github.com/agauniyal/rang/ inline bool is_color_terminal() SPDLOG_NOEXCEPT diff --git a/include/spdlog/details/pattern_formatter.h b/include/spdlog/details/pattern_formatter.h index d6a723ae..5d71ecf0 100644 --- a/include/spdlog/details/pattern_formatter.h +++ b/include/spdlog/details/pattern_formatter.h @@ -729,7 +729,8 @@ public: void format(const details::log_msg &msg, const std::tm &, fmt::memory_buffer &dest) override { - if(padinfo_.width_) { + if (padinfo_.width_) + { scoped_pad p(msg.payload, padinfo_, dest); fmt_helper::append_string_view(msg.payload, dest); } diff --git a/include/spdlog/spdlog.h b/include/spdlog/spdlog.h index 0b6a564a..c314c07b 100644 --- a/include/spdlog/spdlog.h +++ b/include/spdlog/spdlog.h @@ -303,7 +303,6 @@ inline void critical(const wchar_t *fmt, const Args &... args) // SPDLOG_LEVEL_OFF // - #if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_TRACE #define SPDLOG_LOGGER_TRACE(logger, ...) logger->trace(__VA_ARGS__) #define SPDLOG_TRACE(...) spdlog::trace(__VA_ARGS__)