summaryrefslogtreecommitdiffstats
path: root/src/corelib/global/qlogging.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/global/qlogging.cpp')
-rw-r--r--src/corelib/global/qlogging.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp
index 063e94069f..0a261acc77 100644
--- a/src/corelib/global/qlogging.cpp
+++ b/src/corelib/global/qlogging.cpp
@@ -549,6 +549,7 @@ static const char functionTokenC[] = "%{function}";
static const char pidTokenC[] = "%{pid}";
static const char appnameTokenC[] = "%{appname}";
static const char threadidTokenC[] = "%{threadid}";
+static const char ifCategoryTokenC[] = "%{if-category}";
static const char ifDebugTokenC[] = "%{if-debug}";
static const char ifWarningTokenC[] = "%{if-warning}";
static const char ifCriticalTokenC[] = "%{if-critical}";
@@ -556,7 +557,7 @@ static const char ifFatalTokenC[] = "%{if-fatal}";
static const char endifTokenC[] = "%{endif}";
static const char emptyTokenC[] = "";
-static const char defaultPattern[] = "%{message}";
+static const char defaultPattern[] = "%{if-category}%{category}: %{endif}%{message}";
struct QMessagePattern {
@@ -675,6 +676,7 @@ void QMessagePattern::setPattern(const QString &pattern)
tokens[i] = LEVEL; \
inIf = true; \
}
+ IF_TOKEN(ifCategoryTokenC)
IF_TOKEN(ifDebugTokenC)
IF_TOKEN(ifWarningTokenC)
IF_TOKEN(ifCriticalTokenC)
@@ -837,6 +839,9 @@ Q_CORE_EXPORT QString qMessageFormatString(QtMsgType type, const QMessageLogCont
message.append(QLatin1String("0x"));
message.append(QString::number(qlonglong(QThread::currentThread()->currentThread()), 16));
#endif
+ } else if (token == ifCategoryTokenC) {
+ if (!context.category || (strcmp(context.category, "default") == 0))
+ skip = true;
#define HANDLE_IF_TOKEN(LEVEL) \
} else if (token == if##LEVEL##TokenC) { \
skip = type != Qt##LEVEL##Msg;
@@ -927,7 +932,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 (QLoggingCategory *defaultCategory = &QLoggingCategory::defaultCategory()) {
+ if (QLoggingCategory *defaultCategory = QLoggingCategory::defaultCategory()) {
if (!defaultCategory->isEnabled(msgType))
return;
}
@@ -1108,6 +1113,7 @@ void qErrnoWarning(int code, const char *msg, ...)
\table
\header \li Placeholder \li Description
\row \li \c %{appname} \li QCoreApplication::applicationName()
+ \row \li \c %{category} \li Logging category
\row \li \c %{file} \li Path to source file
\row \li \c %{function} \li Function
\row \li \c %{line} \li Line in source file