From 380233b727215ca0ffe026f8f938f47b096f60fa Mon Sep 17 00:00:00 2001 From: Asit Kumar Dhal Date: Sat, 17 Jun 2017 17:24:16 +0200 Subject: [PATCH] mend --- include/spdlog/details/logger_impl.h | 78 ++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/include/spdlog/details/logger_impl.h b/include/spdlog/details/logger_impl.h index 9ea78eb4..2619ccf8 100644 --- a/include/spdlog/details/logger_impl.h +++ b/include/spdlog/details/logger_impl.h @@ -380,6 +380,84 @@ inline void spdlog::logger::critical(const wchar_t* fmt, const Args&... args) { log(level::critical, fmt, args...); } + +// +// conditional logging +// + +template +inline void spdlog::logger::log_if(const bool flag, level::level_enum lvl, const wchar_t* msg) +{ + if (flag) + { + log(lvl, msg); + } +} + +template +inline void spdlog::logger::log_if(const bool flag, level::level_enum lvl, const wchar_t* fmt, const Args&... args) +{ + if (flag) + { + log(lvl, fmt, args); + } +} + +template +inline void spdlog::logger::trace_if(const bool flag, const wchar_t* fmt, const Args&... args) +{ + if (flag) + { + log(level::trace, fmt, args...); + } +} + +template +inline void spdlog::logger::debug_if(const bool flag, const wchar_t* fmt, const Args&... args) +{ + if (flag) + { + log(level::debug, fmt, args...); + } +} + +template +inline void spdlog::logger::info_if(const bool flag, const wchar_t* fmt, const Args&... args) +{ + if (flag) + { + log(level::info, fmt, args...); + } +} + + +template +inline void spdlog::logger::warn_if(const bool flag, const wchar_t* fmt, const Args&... args) +{ + if (flag) + { + log(level::warn, fmt, args...); + } +} + +template +inline void spdlog::logger::error_if(const bool flag, const wchar_t* fmt, const Args&... args) +{ + if (flag) + { + log(level::err, fmt, args...); + } +} + +template +inline void spdlog::logger::critical_if(const bool flag, const wchar_t* fmt, const Args&... args) +{ + if (flag) + { + log(level::critical, fmt, args...); + } +} + #endif // SPDLOG_WCHAR_TO_UTF8_SUPPORT