summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io/qloggingcategory
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@theqtcompany.com>2014-12-04 16:57:32 +0100
committerKai Koehne <kai.koehne@theqtcompany.com>2015-01-09 13:14:05 +0100
commitef6279fd516befc09d4a6b3664a727a013b82c19 (patch)
tree4365a6dfb7c8d8e3094f35eb1ffe8fb8a23088cf /tests/auto/corelib/io/qloggingcategory
parent4c980aedc17c1da8f7160989fbb845ea72b36f44 (diff)
Add QtInfoMsg
Add an 'info' message type that can be used for messages that are neither warnings (QtWarningMsg), nor for debugging only (QtDebugMsg). This is useful mainly for applications that do not have to adhere to the 'do not print anything by default' paradigm that we have for the Qt libraries itself. [ChangeLog][QtCore][Logging] QtInfoMsg got added as a new QtMsgType. Use the new qInfo(), qCInfo() macros to log to it. Change-Id: I810995d63de46c41a9a99a34d37c0d417fa87a05 Reviewed-by: Jason McDonald <macadder1@gmail.com>
Diffstat (limited to 'tests/auto/corelib/io/qloggingcategory')
-rw-r--r--tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp84
1 files changed, 75 insertions, 9 deletions
diff --git a/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp b/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp
index 2e4740c8d9..dc0081f7ac 100644
--- a/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp
+++ b/tests/auto/corelib/io/qloggingcategory/tst_qloggingcategory.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2015 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the test suite of the Qt Toolkit.
@@ -57,6 +57,7 @@ QByteArray qMyMessageFormatString(QtMsgType type, const QMessageLogContext &cont
message.append(context.category);
switch (type) {
case QtDebugMsg: message.append(".debug"); break;
+ case QtInfoMsg: message.append(".info"); break;
case QtWarningMsg: message.append(".warning"); break;
case QtCriticalMsg:message.append(".critical"); break;
case QtFatalMsg: message.append(".fatal"); break;
@@ -339,6 +340,11 @@ private slots:
qDebug("%s", "Check debug with no filter active");
QCOMPARE(logMessage, buf);
+ // Check default info
+ buf = QStringLiteral("default.info: Check info with no filter active");
+ qInfo("%s", "Check info with no filter active");
+ QCOMPARE(logMessage, buf);
+
// Check default warning
buf = QStringLiteral("default.warning: Check warning with no filter active");
qWarning("%s", "Check warning with no filter active");
@@ -407,6 +413,13 @@ private slots:
qCDebug(defaultCategory, "Check debug with no filter active");
QCOMPARE(logMessage, buf);
+ // Check default info
+ buf = QStringLiteral("default.info: Check info with no filter active");
+ qCInfo(defaultCategory) << "Check info with no filter active";
+ QCOMPARE(logMessage, buf);
+ qCInfo(defaultCategory, "Check info 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";
@@ -432,6 +445,11 @@ private slots:
qCDebug(customCategory) << "Check debug with no filter active";
QCOMPARE(logMessage, buf);
+ // Check custom info
+ buf = QStringLiteral("custom.info: Check info with no filter active");
+ qCInfo(customCategory) << "Check info with no filter active";
+ QCOMPARE(logMessage, buf);
+
// Check custom warning
buf = QStringLiteral("custom.warning: Check warning with no filter active");
qCWarning(customCategory) << "Check warning with no filter active";
@@ -493,7 +511,7 @@ private slots:
usedefaultformat = false;
}
- // Check the Debug, Warning and critical without having category active. should be active.
+ // Check the Debug, Info, Warning and critical without having category active. should be active.
void checkNoCategoryLogActive()
{
// Check default debug
@@ -501,6 +519,11 @@ private slots:
qDebug() << "Check default Debug with no log active";
QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf));
+ // Check default info
+ buf = QStringLiteral("default.info: Check default Info with no log active");
+ qInfo() << "Check default Info with no log active";
+ QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf));
+
// Check default warning
buf = QStringLiteral("default.warning: Check default Warning with no log active");
qWarning() << "Check default Warning with no log active";
@@ -514,8 +537,11 @@ private slots:
// Check category debug
buf = QStringLiteral("tst.log.debug: Check category Debug with no log active");
qCDebug(TST_LOG) << "Check category Debug with no log active";
- QCOMPARE(logMessage, buf);
+ // Check category info
+ buf = QStringLiteral("tst.log.info: Check category Info with no log active");
+ qCInfo(TST_LOG) << "Check category Info with no log active";
+ QCOMPARE(logMessage, buf);
// Check default warning
buf = QStringLiteral("tst.log.warning: Check category Warning with no log active");
@@ -550,6 +576,9 @@ private slots:
qCDebug(TST_LOG) << "DebugType";
buf = QStringLiteral("tst.log.debug: DebugType");
QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf));
+ qCInfo(TST_LOG) << "InfoType";
+ buf = QStringLiteral("tst.log.info: InfoType");
+ QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf));
qCWarning(TST_LOG) << "WarningType";
buf = QStringLiteral("tst.log.warning: WarningType");
QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf));
@@ -561,11 +590,13 @@ private slots:
void checkLegacyLogs()
{
logMessage = "";
+ // all are on by default
qDebug() << "DefaultDebug";
QString buf = QStringLiteral("default.debug: DefaultDebug");
QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf));
-
- // debug off by default, warning and critical are on
+ qInfo() << "DefaultInfo";
+ buf = QStringLiteral("default.info: DefaultInfo");
+ QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf));
qWarning() << "DefaultWarning";
buf = QStringLiteral("default.warning: DefaultWarning");
QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf));
@@ -573,12 +604,16 @@ private slots:
buf = QStringLiteral("default.critical: DefaultCritical");
QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf));
- // Enable debug
- _config->addKey("default.debug", true);
+ // Disable debug
+ _config->addKey("default.debug", false);
QLoggingCategory::setFilterRules(_config->array());
+ logMessage = "no change";
qDebug() << "DefaultDebug1";
- buf = QStringLiteral("default.debug: DefaultDebug1");
+ buf = QStringLiteral("no change");
+ QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf));
+ qInfo() << "DefaultInfo1";
+ buf = QStringLiteral("default.info: DefaultInfo1");
QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf));
qWarning() << "DefaultWarning1";
buf = QStringLiteral("default.warning: DefaultWarning1");
@@ -587,7 +622,11 @@ private slots:
buf = QStringLiteral("default.critical: DefaultCritical1");
QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf));
- // Disable warning
+ _config->clear();
+ QLoggingCategory::setFilterRules(_config->array());
+
+ // Disable info, warning
+ _config->addKey("default.info", false);
_config->addKey("default.warning", false);
QLoggingCategory::setFilterRules(_config->array());
@@ -595,6 +634,9 @@ private slots:
buf = QStringLiteral("default.debug: DefaultDebug2");
QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf));
logMessage = "no change";
+ qInfo() << "DefaultInfo2";
+ buf = QStringLiteral("no change");
+ QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf));
qWarning() << "DefaultWarning2";
buf = QStringLiteral("no change");
QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf));
@@ -611,6 +653,8 @@ private slots:
qDebug() << "DefaultDebug3";
buf = QStringLiteral("no change");
QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf));
+ qInfo() << "DefaultInfo3";
+ QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf));
qWarning() << "DefaultWarning3";
QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf));
qCritical() << "DefaultCritical3";
@@ -619,6 +663,7 @@ private slots:
// Enable default logs
_config->addKey("default.critical", true);
_config->addKey("default.warning", true);
+ _config->addKey("default.info", true);
_config->addKey("default.debug", true);
QLoggingCategory::setFilterRules(_config->array());
@@ -626,6 +671,9 @@ private slots:
qDebug() << "DefaultDebug4";
buf = QStringLiteral("default.debug: DefaultDebug4");
QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf));
+ qInfo() << "DefaultInfo4";
+ buf = QStringLiteral("default.info: DefaultInfo4");
+ QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf));
qWarning() << "DefaultWarning4";
buf = QStringLiteral("default.warning: DefaultWarning4");
QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf));
@@ -642,6 +690,8 @@ private slots:
buf = QStringLiteral("no change");
qDebug() << "DefaultDebug5";
QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf));
+ qDebug() << "DefaultInfo5";
+ QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf));
qWarning() << "DefaultWarning5";
QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf));
qCritical() << "DefaultCritical5";
@@ -711,6 +761,7 @@ private slots:
QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf));
logMessage = "no change";
buf = QStringLiteral("no change");
+ qCInfo(Digia_Oulu_Office_com) << "Info: Digia.Oulu.Office.com 4";
qCWarning(Digia_Oulu_Office_com) << "Warning: Digia.Oulu.Office.com 4";
qCCritical(Digia_Berlin_Office_com) << "Critical: Digia.Berlin.Office.com 4";
QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf));
@@ -723,6 +774,9 @@ private slots:
qCDebug(Digia_Oslo_Office_com) << "Debug: Digia.Oslo.Office.com 5";
buf = QStringLiteral("Digia.Oslo.Office.com.debug: Debug: Digia.Oslo.Office.com 5");
QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf));
+ qCInfo(Digia_Oulu_Office_com) << "Info: Digia.Oulu.Office.com 5";
+ buf = QStringLiteral("Digia.Oulu.Office.com.info: Info: Digia.Oulu.Office.com 5");
+ QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf));
qCWarning(Digia_Oulu_Office_com) << "Warning: Digia.Oulu.Office.com 5";
buf = QStringLiteral("Digia.Oulu.Office.com.warning: Warning: Digia.Oulu.Office.com 5");
QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf));
@@ -737,6 +791,7 @@ private slots:
logMessage = "no change";
buf = QStringLiteral("no change");
qCDebug(Digia_Oslo_Office_com) << "Debug: Digia.Oslo.Office.com 6";
+ qCInfo(Digia_Oslo_Office_com) << "Info: Digia.Oslo.Office.com 6";
qCWarning(Digia_Oulu_Office_com) << "Warning: Digia.Oulu.Office.com 6";
qCCritical(Digia_Berlin_Office_com) << "Critical: Digia.Berlin.Office.com 6";
QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf));
@@ -747,6 +802,9 @@ private slots:
qCDebug(Digia_Oslo_Office_com) << "Debug: Digia.Oslo.Office.com 7";
buf = QStringLiteral("Digia.Oslo.Office.com.debug: Debug: Digia.Oslo.Office.com 7");
QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf));
+ qCInfo(Digia_Oulu_Office_com) << "Info: Digia.Oulu.Office.com 7";
+ buf = QStringLiteral("Digia.Oulu.Office.com.info: Info: Digia.Oulu.Office.com 7");
+ QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf));
qCWarning(Digia_Oulu_Office_com) << "Warning: Digia.Oulu.Office.com 7";
buf = QStringLiteral("Digia.Oulu.Office.com.warning: Warning: Digia.Oulu.Office.com 7");
QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf));
@@ -770,6 +828,10 @@ private slots:
qCDebug(mycategoryobject) << "My Category Object";
QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf));
+ buf = QStringLiteral("LoggingCategoryObject.info: My Category Object");
+ qCInfo(mycategoryobject) << "My Category Object";
+ QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf));
+
buf = QStringLiteral("LoggingCategoryObject.warning: My Category Object");
qCWarning(mycategoryobject) << "My Category Object";
QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf));
@@ -787,6 +849,10 @@ private slots:
qCWarning(mycategoryobject) << "My Category Object";
QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf));
+ buf = QStringLiteral("LoggingCategoryObject.info: My Category Object");
+ qCInfo(mycategoryobject) << "My Category Object";
+ QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf));
+
buf = QStringLiteral("LoggingCategoryObject.critical: My Category Object");
qCCritical(mycategoryobject) << "My Category Object";
QCOMPARE(cleanLogLine(logMessage), cleanLogLine(buf));