summaryrefslogtreecommitdiffstats
path: root/src/corelib/global/qlogging.cpp
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2018-01-16 15:08:26 +0100
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2018-01-16 18:02:02 +0000
commitea7a9d694b8548f39d4e66684793ad17be837a66 (patch)
tree384e652033b5f652636e71978a761ca430210352 /src/corelib/global/qlogging.cpp
parent6121c400181419a4a2a0faf842efdde8b59f87a5 (diff)
logging: Factor out how to determine if a category is the default category
Change-Id: I00a94c8c3ce2c0cba5263e6fbc499794dc7ef38f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/corelib/global/qlogging.cpp')
-rw-r--r--src/corelib/global/qlogging.cpp9
1 files changed, 7 insertions, 2 deletions
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;