diff options
author | gabime <gmelman1@gmail.com> | 2019-06-19 17:13:48 +0300 |
---|---|---|
committer | gabime <gmelman1@gmail.com> | 2019-06-19 17:13:48 +0300 |
commit | 74e2aa9c66924d7a72b304c472446f028e3a08c7 (patch) | |
tree | 2c8936a8e6e761af51a728e75bdfa1ff5cda929d /include/spdlog | |
parent | b9cc158e522c17ff225d1ca6c270428b40eed683 (diff) |
Micoro optimize macros
Diffstat (limited to 'include/spdlog')
-rw-r--r-- | include/spdlog/logger.h | 16 | ||||
-rw-r--r-- | include/spdlog/spdlog.h | 5 |
2 files changed, 13 insertions, 8 deletions
diff --git a/include/spdlog/logger.h b/include/spdlog/logger.h index b0e5d2f9..bc627c4b 100644 --- a/include/spdlog/logger.h +++ b/include/spdlog/logger.h @@ -63,13 +63,8 @@ public: void swap(spdlog::logger &other); template<typename... Args> - void log(source_loc loc, level::level_enum lvl, const char *fmt, const Args &... args) + void force_log(source_loc loc, level::level_enum lvl, const char *fmt, const Args &... args) { - if (!should_log(lvl)) - { - return; - } - try { fmt::memory_buffer buf; @@ -88,6 +83,15 @@ public: } template<typename... Args> + void log(source_loc loc, level::level_enum lvl, const char *fmt, const Args &... args) + { + if (should_log(lvl)) + { + force_log(loc, lvl, fmt, args...); + } + } + + template<typename... Args> void log(level::level_enum lvl, const char *fmt, const Args &... args) { log(source_loc{}, lvl, fmt, args...); diff --git a/include/spdlog/spdlog.h b/include/spdlog/spdlog.h index dfa42145..9e8070c3 100644 --- a/include/spdlog/spdlog.h +++ b/include/spdlog/spdlog.h @@ -27,8 +27,9 @@ using default_factory = synchronous_factory; // Create and register a logger with a templated sink type // The logger's level, formatter and flush level will be set according the // global settings. +// // Example: -// spdlog::create<daily_file_sink_st>("logger_name", "dailylog_filename", 11, 59); +// spdlog::create<daily_file_sink_st>("logger_name", "dailylog_filename", 11, 59); template<typename Sink, typename... SinkArgs> inline std::shared_ptr<spdlog::logger> create(std::string logger_name, SinkArgs &&... sink_args) { @@ -267,7 +268,7 @@ inline void critical(const wchar_t *fmt, const Args &... args) do \ { \ if (logger->should_log(level)) \ - logger->log(spdlog::source_loc{__FILE__, __LINE__, SPDLOG_FUNCTION}, level, __VA_ARGS__); \ + logger->force_log(spdlog::source_loc{__FILE__, __LINE__, SPDLOG_FUNCTION}, level, __VA_ARGS__); \ } while (0) #if SPDLOG_ACTIVE_LEVEL <= SPDLOG_LEVEL_TRACE |