From ea7a9d694b8548f39d4e66684793ad17be837a66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 16 Jan 2018 15:08:26 +0100 Subject: logging: Factor out how to determine if a category is the default category Change-Id: I00a94c8c3ce2c0cba5263e6fbc499794dc7ef38f Reviewed-by: Simon Hausmann --- src/corelib/global/qlogging.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/corelib/global/qlogging.cpp') diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index e7305f4106..a3cab2b627 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -194,6 +194,11 @@ static bool isFatal(QtMsgType msgType) return false; } +static bool isDefaultCategory(const char *category) +{ + return !category || strcmp(category, "default") == 0; +} + static bool willLogToConsole() { #if defined(Q_OS_WINRT) @@ -1487,7 +1492,7 @@ QString qFormatLogMessage(QtMsgType type, const QMessageLogContext &context, con } #endif // !QT_BOOTSTRAPPED } else if (token == ifCategoryTokenC) { - if (!context.category || (strcmp(context.category, "default") == 0)) + if (isDefaultCategory(context.category)) skip = true; #define HANDLE_IF_TOKEN(LEVEL) \ } else if (token == if##LEVEL##TokenC) { \ @@ -1709,7 +1714,7 @@ static void qt_message_print(QtMsgType msgType, const QMessageLogContext &contex { #ifndef QT_BOOTSTRAPPED // qDebug, qWarning, ... macros do not check whether category is enabled - if (!context.category || (strcmp(context.category, "default") == 0)) { + if (isDefaultCategory(context.category)) { if (QLoggingCategory *defaultCategory = QLoggingCategory::defaultCategory()) { if (!defaultCategory->isEnabled(msgType)) return; -- cgit v1.2.3