aboutsummaryrefslogtreecommitdiff
path: root/src/logging.h
diff options
context:
space:
mode:
authorlaanwj <126646+laanwj@users.noreply.github.com>2022-05-24 19:52:49 +0200
committerlaanwj <126646+laanwj@users.noreply.github.com>2022-05-25 11:26:15 +0200
commitbd971bffb02c7b06aac9a479f7e5ed8f71de2bec (patch)
treeab24eb41471b950c57db65c3648e3c0c56a4a487 /src/logging.h
parent90e49c1ececd6296c6ec6109cea525a208c0626e (diff)
logging: Unconditionally log levels >= WARN
Messages with level `WARN` or higher should be logged even when the category is not provided with `-debug=`, to make sure important warnings are not lost.
Diffstat (limited to 'src/logging.h')
-rw-r--r--src/logging.h13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/logging.h b/src/logging.h
index 421c3395c2..8b4459400b 100644
--- a/src/logging.h
+++ b/src/logging.h
@@ -166,9 +166,14 @@ namespace BCLog {
BCLog::Logger& LogInstance();
-/** Return true if log accepts specified category */
-static inline bool LogAcceptCategory(BCLog::LogFlags category)
+/** Return true if log accepts specified category, at the specified level. */
+static inline bool LogAcceptCategory(BCLog::LogFlags category, BCLog::Level level)
{
+ // Log messages at Warning and Error level unconditionally, so that
+ // important troubleshooting information doesn't get lost.
+ if (level >= BCLog::Level::Warning) {
+ return true;
+ }
return LogInstance().WillLogCategory(category);
}
@@ -203,14 +208,14 @@ static inline void LogPrintf_(const std::string& logging_function, const std::st
// evaluating arguments when logging for the category is not enabled.
#define LogPrint(category, ...) \
do { \
- if (LogAcceptCategory((category))) { \
+ if (LogAcceptCategory((category), BCLog::Level::Debug)) { \
LogPrintLevel_(category, BCLog::Level::None, __VA_ARGS__); \
} \
} while (0)
#define LogPrintLevel(level, category, ...) \
do { \
- if (LogAcceptCategory((category))) { \
+ if (LogAcceptCategory((category), (level))) { \
LogPrintLevel_(category, level, __VA_ARGS__); \
} \
} while (0)