diff --git a/bench/formatter-bench.cpp b/bench/formatter-bench.cpp index fff16e4b..857f4c78 100644 --- a/bench/formatter-bench.cpp +++ b/bench/formatter-bench.cpp @@ -48,12 +48,12 @@ void bench_formatters() auto pattern = std::string("%") + flag; benchmark::RegisterBenchmark(pattern.c_str(), bench_formatter, pattern); -// pattern = std::string("%16") + flag; -// benchmark::RegisterBenchmark(pattern.c_str(), bench_formatter, pattern); -// -// // bench center padding -// pattern = std::string("%=16") + flag; -// benchmark::RegisterBenchmark(pattern.c_str(), bench_formatter, pattern); + // pattern = std::string("%16") + flag; + // benchmark::RegisterBenchmark(pattern.c_str(), bench_formatter, pattern); + // + // // bench center padding + // pattern = std::string("%=16") + flag; + // benchmark::RegisterBenchmark(pattern.c_str(), bench_formatter, pattern); } // complex patterns @@ -72,14 +72,14 @@ int main(int argc, char *argv[]) { spdlog::set_pattern("[%^%l%$] %v"); - if(argc != 2) + if (argc != 2) { spdlog::error("Usage: {} (or \"all\" to bench all)", argv[0]); exit(1); } std::string pattern = argv[1]; - if(pattern == "all") + if (pattern == "all") { bench_formatters(); } diff --git a/bench/latency.cpp b/bench/latency.cpp index 67274b62..2a7787d6 100644 --- a/bench/latency.cpp +++ b/bench/latency.cpp @@ -73,7 +73,7 @@ void bench_disabled_macro(benchmark::State &state, std::shared_ptrshould_log(spdlog::level::trace))\ - logger->log(spdlog::source_loc{SPDLOG_FILE_BASENAME(__FILE__), __LINE__, SPDLOG_FUNCTION}, spdlog::level::trace, __VA_ARGS__) +#define SPDLOG_LOGGER_TRACE(logger, ...) \ + if (logger->should_log(spdlog::level::trace)) \ + logger->log(spdlog::source_loc{SPDLOG_FILE_BASENAME(__FILE__), __LINE__, SPDLOG_FUNCTION}, spdlog::level::trace, __VA_ARGS__) #define SPDLOG_TRACE(...) SPDLOG_LOGGER_TRACE(spdlog::default_logger_raw(), __VA_ARGS__) #else #define SPDLOG_LOGGER_TRACE(logger, ...) (void)0 @@ -328,7 +326,8 @@ inline void critical(const wchar_t *fmt, const Args &... args) #endif #if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_DEBUG -#define SPDLOG_LOGGER_DEBUG(logger, ...) logger->log(spdlog::source_loc{SPDLOG_FILE_BASENAME(__FILE__), __LINE__, SPDLOG_FUNCTION}, spdlog::level::debug, __VA_ARGS__) +#define SPDLOG_LOGGER_DEBUG(logger, ...) \ + logger->log(spdlog::source_loc{SPDLOG_FILE_BASENAME(__FILE__), __LINE__, SPDLOG_FUNCTION}, spdlog::level::debug, __VA_ARGS__) #define SPDLOG_DEBUG(...) SPDLOG_LOGGER_DEBUG(spdlog::default_logger_raw(), __VA_ARGS__) #else #define SPDLOG_LOGGER_DEBUG(logger, ...) (void)0 @@ -336,7 +335,8 @@ inline void critical(const wchar_t *fmt, const Args &... args) #endif #if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_INFO -#define SPDLOG_LOGGER_INFO(logger, ...) logger->log(spdlog::source_loc{SPDLOG_FILE_BASENAME(__FILE__), __LINE__, SPDLOG_FUNCTION}, spdlog::level::info, __VA_ARGS__) +#define SPDLOG_LOGGER_INFO(logger, ...) \ + logger->log(spdlog::source_loc{SPDLOG_FILE_BASENAME(__FILE__), __LINE__, SPDLOG_FUNCTION}, spdlog::level::info, __VA_ARGS__) #define SPDLOG_INFO(...) SPDLOG_LOGGER_INFO(spdlog::default_logger_raw(), __VA_ARGS__) #else #define SPDLOG_LOGGER_INFO(logger, ...) (void)0 @@ -344,7 +344,8 @@ inline void critical(const wchar_t *fmt, const Args &... args) #endif #if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_WARN -#define SPDLOG_LOGGER_WARN(logger, ...) logger->log(spdlog::source_loc{SPDLOG_FILE_BASENAME(__FILE__), __LINE__, SPDLOG_FUNCTION}, spdlog::level::warn, __VA_ARGS__) +#define SPDLOG_LOGGER_WARN(logger, ...) \ + logger->log(spdlog::source_loc{SPDLOG_FILE_BASENAME(__FILE__), __LINE__, SPDLOG_FUNCTION}, spdlog::level::warn, __VA_ARGS__) #define SPDLOG_WARN(...) SPDLOG_LOGGER_WARN(spdlog::default_logger_raw(), __VA_ARGS__) #else #define SPDLOG_LOGGER_WARN(logger, ...) (void)0 @@ -352,7 +353,8 @@ inline void critical(const wchar_t *fmt, const Args &... args) #endif #if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_ERROR -#define SPDLOG_LOGGER_ERROR(logger, ...) logger->log(spdlog::source_loc{SPDLOG_FILE_BASENAME(__FILE__), __LINE__, SPDLOG_FUNCTION}, spdlog::level::err, __VA_ARGS__) +#define SPDLOG_LOGGER_ERROR(logger, ...) \ + logger->log(spdlog::source_loc{SPDLOG_FILE_BASENAME(__FILE__), __LINE__, SPDLOG_FUNCTION}, spdlog::level::err, __VA_ARGS__) #define SPDLOG_ERROR(...) SPDLOG_LOGGER_ERROR(spdlog::default_logger_raw(), __VA_ARGS__) #else #define SPDLOG_LOGGER_ERROR(logger, ...) (void)0 @@ -360,7 +362,8 @@ inline void critical(const wchar_t *fmt, const Args &... args) #endif #if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_CRITICAL -#define SPDLOG_LOGGER_CRITICAL(logger, ...) logger->log(spdlog::source_loc{SPDLOG_FILE_BASENAME(__FILE__), __LINE__, SPDLOG_FUNCTION}, spdlog::level::critical, __VA_ARGS__) +#define SPDLOG_LOGGER_CRITICAL(logger, ...) \ + logger->log(spdlog::source_loc{SPDLOG_FILE_BASENAME(__FILE__), __LINE__, SPDLOG_FUNCTION}, spdlog::level::critical, __VA_ARGS__) #define SPDLOG_CRITICAL(...) SPDLOG_LOGGER_CRITICAL(spdlog::default_logger_raw(), __VA_ARGS__) #else #define SPDLOG_LOGGER_CRITICAL(logger, ...) (void)0