mirror of
https://github.com/gabime/spdlog.git
synced 2025-09-30 10:29:02 +08:00
Removed all *_if functions (trace_if, debug_if, info_if,..) because they are redundant and confusing way to preform if
This commit is contained in:
@@ -153,78 +153,6 @@ inline void spdlog::logger::critical(const char* fmt, const Arg1 &arg1, const Ar
|
||||
log(level::critical, fmt, arg1, args...);
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
inline void spdlog::logger::log_if(const bool flag, level::level_enum lvl, const char* msg)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
log(lvl, msg);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void spdlog::logger::log_if(const bool flag, level::level_enum lvl, const T& msg)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
log(lvl, msg);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Arg1, typename... Args>
|
||||
inline void spdlog::logger::trace_if(const bool flag, const char* fmt, const Arg1 &arg1, const Args&... args)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
log(level::trace, fmt, arg1, args...);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Arg1, typename... Args>
|
||||
inline void spdlog::logger::debug_if(const bool flag, const char* fmt, const Arg1 &arg1, const Args&... args)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
log(level::debug, fmt, arg1, args...);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Arg1, typename... Args>
|
||||
inline void spdlog::logger::info_if(const bool flag, const char* fmt, const Arg1 &arg1, const Args&... args)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
log(level::info, fmt, arg1, args...);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Arg1, typename... Args>
|
||||
inline void spdlog::logger::warn_if(const bool flag, const char* fmt, const Arg1& arg1, const Args&... args)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
log(level::warn, fmt, arg1, args...);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Arg1, typename... Args>
|
||||
inline void spdlog::logger::error_if(const bool flag, const char* fmt, const Arg1 &arg1, const Args&... args)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
log(level::err, fmt, arg1, args...);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Arg1, typename... Args>
|
||||
inline void spdlog::logger::critical_if(const bool flag, const char* fmt, const Arg1 &arg1, const Args&... args)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
log(level::critical, fmt, arg1, args...);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
inline void spdlog::logger::trace(const T& msg)
|
||||
@@ -264,59 +192,6 @@ inline void spdlog::logger::critical(const T& msg)
|
||||
log(level::critical, msg);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void spdlog::logger::trace_if(const bool flag, const T& msg)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
log(level::trace, msg);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void spdlog::logger::debug_if(const bool flag, const T& msg)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
log(level::debug, msg);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void spdlog::logger::info_if(const bool flag, const T& msg)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
log(level::info, msg);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void spdlog::logger::warn_if(const bool flag, const T& msg)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
log(level::warn, msg);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void spdlog::logger::error_if(const bool flag, const T& msg)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
log(level::err, msg);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void spdlog::logger::critical_if(const bool flag, const T& msg)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
log(level::critical, msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef SPDLOG_WCHAR_TO_UTF8_SUPPORT
|
||||
@@ -377,81 +252,6 @@ inline void spdlog::logger::critical(const wchar_t* fmt, const Args&... args)
|
||||
log(level::critical, fmt, args...);
|
||||
}
|
||||
|
||||
//
|
||||
// conditional logging
|
||||
//
|
||||
|
||||
template <typename... Args>
|
||||
inline void spdlog::logger::log_if(const bool flag, level::level_enum lvl, const wchar_t* msg)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
log(lvl, msg);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
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 <typename... Args>
|
||||
inline void spdlog::logger::trace_if(const bool flag, const wchar_t* fmt, const Args&... args)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
log(level::trace, fmt, args...);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
inline void spdlog::logger::debug_if(const bool flag, const wchar_t* fmt, const Args&... args)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
log(level::debug, fmt, args...);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
inline void spdlog::logger::info_if(const bool flag, const wchar_t* fmt, const Args&... args)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
log(level::info, fmt, args...);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <typename... Args>
|
||||
inline void spdlog::logger::warn_if(const bool flag, const wchar_t* fmt, const Args&... args)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
log(level::warn, fmt, args...);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
inline void spdlog::logger::error_if(const bool flag, const wchar_t* fmt, const Args&... args)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
log(level::err, fmt, args...);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
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
|
||||
|
@@ -44,14 +44,6 @@ public:
|
||||
template <typename Arg1, typename... Args> void error(const char* fmt, const Arg1&, const Args&... args);
|
||||
template <typename Arg1, typename... Args> void critical(const char* fmt, const Arg1&, const Args&... args);
|
||||
|
||||
template <typename... Args> void log_if(const bool flag, level::level_enum lvl, const char* fmt, const Args&... args);
|
||||
template <typename... Args> void log_if(const bool flag, level::level_enum lvl, const char* msg);
|
||||
template <typename Arg1, typename... Args> void trace_if(const bool flag, const char* fmt, const Arg1&, const Args&... args);
|
||||
template <typename Arg1, typename... Args> void debug_if(const bool flag, const char* fmt, const Arg1&, const Args&... args);
|
||||
template <typename Arg1, typename... Args> void info_if(const bool flag, const char* fmt, const Arg1&, const Args&... args);
|
||||
template <typename Arg1, typename... Args> void warn_if(const bool flag, const char* fmt, const Arg1&, const Args&... args);
|
||||
template <typename Arg1, typename... Args> void error_if(const bool flag, const char* fmt, const Arg1&, const Args&... args);
|
||||
template <typename Arg1, typename... Args> void critical_if(const bool flag, const char* fmt, const Arg1&, const Args&... args);
|
||||
|
||||
#ifdef SPDLOG_WCHAR_TO_UTF8_SUPPORT
|
||||
template <typename... Args> void log(level::level_enum lvl, const wchar_t* msg);
|
||||
@@ -62,15 +54,6 @@ public:
|
||||
template <typename... Args> void warn(const wchar_t* fmt, const Args&... args);
|
||||
template <typename... Args> void error(const wchar_t* fmt, const Args&... args);
|
||||
template <typename... Args> void critical(const wchar_t* fmt, const Args&... args);
|
||||
|
||||
template <typename... Args> void log_if(const bool flag, level::level_enum lvl, const wchar_t* msg);
|
||||
template <typename... Args> void log_if(const bool flag, level::level_enum lvl, const wchar_t* fmt, const Args&... args);
|
||||
template <typename... Args> void trace_if(const bool flag, const wchar_t* fmt, const Args&... args);
|
||||
template <typename... Args> void debug_if(const bool flag, const wchar_t* fmt, const Args&... args);
|
||||
template <typename... Args> void info_if(const bool flag, const wchar_t* fmt, const Args&... args);
|
||||
template <typename... Args> void warn_if(const bool flag, const wchar_t* fmt, const Args&... args);
|
||||
template <typename... Args> void error_if(const bool flag, const wchar_t* fmt, const Args&... args);
|
||||
template <typename... Args> void critical_if(const bool flag, const wchar_t* fmt, const Args&... args);
|
||||
#endif // SPDLOG_WCHAR_TO_UTF8_SUPPORT
|
||||
|
||||
template <typename T> void log(level::level_enum lvl, const T&);
|
||||
|
@@ -162,7 +162,6 @@ void drop_all();
|
||||
// SPDLOG_TRACE(my_logger, "some trace message");
|
||||
// SPDLOG_TRACE(my_logger, "another trace message {} {}", 1, 2);
|
||||
// SPDLOG_DEBUG(my_logger, "some debug message {} {}", 3, 4);
|
||||
// SPDLOG_DEBUG_IF(my_logger, true, "some debug message {} {}", 3, 4);
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef SPDLOG_TRACE_ON
|
||||
@@ -170,22 +169,17 @@ void drop_all();
|
||||
#define SPDLOG_STR_HELPER(x) SPDLOG_STR_H(x)
|
||||
#ifdef _MSC_VER
|
||||
#define SPDLOG_TRACE(logger, ...) logger->trace("[ " __FILE__ "(" SPDLOG_STR_HELPER(__LINE__) ") ] " __VA_ARGS__)
|
||||
#define SPDLOG_TRACE_IF(logger, flag, ...) logger->trace_if(flag, "[ " __FILE__ "(" SPDLOG_STR_HELPER(__LINE__) ") ] " __VA_ARGS__)
|
||||
#else
|
||||
#define SPDLOG_TRACE(logger, ...) logger->trace("[ " __FILE__ ":" SPDLOG_STR_HELPER(__LINE__) " ] " __VA_ARGS__)
|
||||
#define SPDLOG_TRACE_IF(logger, flag, ...) logger->trace_if(flag, "[ " __FILE__ ":" SPDLOG_STR_HELPER(__LINE__) " ] " __VA_ARGS__)
|
||||
#endif
|
||||
#else
|
||||
#define SPDLOG_TRACE(logger, ...)
|
||||
#define SPDLOG_TRACE_IF(logger, flag, ...)
|
||||
#endif
|
||||
|
||||
#ifdef SPDLOG_DEBUG_ON
|
||||
#define SPDLOG_DEBUG(logger, ...) logger->debug(__VA_ARGS__)
|
||||
#define SPDLOG_DEBUG_IF(logger, flag, ...) logger->debug_if(flag, __VA_ARGS__)
|
||||
#else
|
||||
#define SPDLOG_DEBUG(logger, ...)
|
||||
#define SPDLOG_DEBUG_IF(logger, flag, ...)
|
||||
#endif
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user