summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io/qloggingcategory
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@digia.com>2014-01-09 15:38:17 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-21 14:58:03 +0100
commitb8a38a6737acd670d92197ca5b009590d9fd8a9c (patch)
tree1b01d7a85a6f35cd420e3cef1bd50490988d7058 /tests/auto/corelib/io/qloggingcategory
parentb152b425f74788b2f2845fb7d1a5032d86b8746d (diff)
Allow printf style for qCDebug, qCWarning, qCCritical macros
Add support for using qCDebug and friends in the 'printf style' way. This allows an almost mechanical conversion of existing qDebug, qWarning, qCritical macros, and allows avoiding the size overhead the streaming style incurs (mostly due to inlined QDebug code). To handle this gracefully we require variadic macros (part of C++11/C99). For compilers not supporting variadic macros we fall back to checking the category in QMessageLogger. [ChangeLog][QtCore][Logging] Allow qCDebug macros to be used in a printf style. Change-Id: I5a8fb135dca504e1d621bb67bf4b2a50c73d41b9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'tests/auto/corelib/io/qloggingcategory')
-rw-r--r--tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp b/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp
index 50268f20a4..26f10385b3 100644
--- a/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp
+++ b/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp
@@ -376,16 +376,22 @@ private slots:
buf = QStringLiteral("default.debug: Check debug with no filter active");
qCDebug(defaultCategory) << "Check debug with no filter active";
QCOMPARE(logMessage, buf);
+ qCDebug(defaultCategory, "Check debug with no filter active");
+ QCOMPARE(logMessage, buf);
// Check default warning
buf = QStringLiteral("default.warning: Check warning with no filter active");
qCWarning(defaultCategory) << "Check warning with no filter active";
QCOMPARE(logMessage, buf);
+ qCWarning(defaultCategory, "Check warning with no filter active");
+ QCOMPARE(logMessage, buf);
// Check default critical
buf = QStringLiteral("default.critical: Check critical with no filter active");
qCCritical(defaultCategory) << "Check critical with no filter active";
QCOMPARE(logMessage, buf);
+ qCCritical(defaultCategory, "Check critical with no filter active");
+ QCOMPARE(logMessage, buf);
QLoggingCategory customCategory("custom");
@@ -412,6 +418,24 @@ private slots:
qCDebug(customCategory) << "Check debug with filter active";
QCOMPARE(logMessage, buf);
+ // Check different macro/category variants
+ buf = QStringLiteral("tst.log.debug: Check debug with no filter active");
+ qCDebug(TST_LOG) << "Check debug with no filter active";
+ QCOMPARE(logMessage, buf);
+ qCDebug(TST_LOG, "Check debug with no filter active");
+ QCOMPARE(logMessage, buf);
+ buf = QStringLiteral("tst.log.warning: Check warning with no filter active");
+ qCWarning(TST_LOG) << "Check warning with no filter active";
+ QCOMPARE(logMessage, buf);
+ qCWarning(TST_LOG, "Check warning with no filter active");
+ QCOMPARE(logMessage, buf);
+ buf = QStringLiteral("tst.log.critical: Check critical with no filter active");
+ qCCritical(TST_LOG) << "Check critical with no filter active";
+ QCOMPARE(logMessage, buf);
+ qCCritical(TST_LOG, "Check critical with no filter active");
+ QCOMPARE(logMessage, buf);
+
+
// reset to default filter
QLoggingCategory::installFilter(0);