aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/logging.h15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/logging.h b/src/logging.h
index 75cd5353c0..e37c0c823b 100644
--- a/src/logging.h
+++ b/src/logging.h
@@ -155,12 +155,13 @@ static inline void LogPrintf(const char* fmt, const Args&... args)
}
}
-template <typename... Args>
-static inline void LogPrint(const BCLog::LogFlags& category, const Args&... args)
-{
- if (LogAcceptCategory((category))) {
- LogPrintf(args...);
- }
-}
+// Use a macro instead of a function for conditional logging to prevent
+// evaluating arguments when logging for the category is not enabled.
+#define LogPrint(category, ...) \
+ do { \
+ if (LogAcceptCategory((category))) { \
+ LogPrintf(__VA_ARGS__); \
+ } \
+ } while (0)
#endif // BITCOIN_LOGGING_H