summaryrefslogtreecommitdiffstats
path: root/src/corelib/doc/snippets
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@digia.com>2014-07-11 12:10:42 +0200
committerKai Koehne <kai.koehne@digia.com>2014-07-15 10:01:29 +0200
commit0fe2713e260c8ecfa463a7075a6b9f1892000691 (patch)
treeb7aa26cfd5b9282f300ee260805b54c9effefb1f /src/corelib/doc/snippets
parent3b0c2b7c1b3ccdfe6867884a7e210bfc63e10f84 (diff)
Improve QLoggingCategory example code in documentation
Don't use a qt.* category in the user documentation: These should be reserved to Qt internal use, and also have special semantics (QtDebugMsg by default off) that might lead to confusion. Also, adapt the camel case naming convention for logging categories defined by the macros. This was the (although somewhat controversial) result of a recent discussion on the development mailing list. Change-Id: Ic7162b47bb2d76550c766bc40dd65ce039e7e3eb Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Alex Blasche <alexander.blasche@digia.com>
Diffstat (limited to 'src/corelib/doc/snippets')
-rw-r--r--src/corelib/doc/snippets/qloggingcategory/main.cpp28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/corelib/doc/snippets/qloggingcategory/main.cpp b/src/corelib/doc/snippets/qloggingcategory/main.cpp
index 628243dbdd..efbf9c55d3 100644
--- a/src/corelib/doc/snippets/qloggingcategory/main.cpp
+++ b/src/corelib/doc/snippets/qloggingcategory/main.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the examples of the Qt Toolkit.
@@ -43,10 +43,10 @@
//![1]
// in a header
-Q_DECLARE_LOGGING_CATEGORY(QT_DRIVER_USB)
+Q_DECLARE_LOGGING_CATEGORY(driverUsb)
// in one source file
-Q_LOGGING_CATEGORY(QT_DRIVER_USB, "qt.driver.usb")
+Q_LOGGING_CATEGORY(driverUsb, "driver.usb")
//![1]
@@ -76,8 +76,8 @@ QLoggingCategory::CategoryFilter oldCategoryFilter;
void myCategoryFilter(QLoggingCategory *category)
{
- // configure qt.driver.usb category here, otherwise forward to to default filter.
- if (qstrcmp(category->categoryName(), "qt.driver.usb") == 0)
+ // configure driver.usb category here, otherwise forward to to default filter.
+ if (qstrcmp(category->categoryName(), "driver.usb") == 0)
category->setEnabled(QtDebugMsg, true);
else
oldCategoryFilter(category);
@@ -89,7 +89,7 @@ int main(int argc, char *argv[])
QCoreApplication a(argc, argv);
//![2]
- QLoggingCategory::setFilterRules(QStringLiteral("qt.driver.usb.debug=true"));
+ QLoggingCategory::setFilterRules(QStringLiteral("driver.usb.debug=true"));
//![2]
//![22]
@@ -103,48 +103,48 @@ oldCategoryFilter = QLoggingCategory::installFilter(myCategoryFilter);
//![3]
//![4]
- // usbEntries() will only be called if QT_DRIVER_USB category is enabled
- qCDebug(QT_DRIVER_USB) << "devices: " << usbEntries();
+ // usbEntries() will only be called if driverUsb category is enabled
+ qCDebug(driverUsb) << "devices: " << usbEntries();
//![4]
{
//![10]
- QLoggingCategory category("qt.driver.usb");
+ QLoggingCategory category("driver.usb");
qCDebug(category) << "a debug message";
//![10]
}
{
//![11]
- QLoggingCategory category("qt.driver.usb");
+ QLoggingCategory category("driver.usb");
qCWarning(category) << "a warning message";
//![11]
}
{
//![12]
- QLoggingCategory category("qt.driver.usb");
+ QLoggingCategory category("driver.usb");
qCCritical(category) << "a critical message";
//![12]
}
{
//![13]
- QLoggingCategory category("qt.driver.usb");
+ QLoggingCategory category("driver.usb");
qCDebug(category, "a debug message logged into category %s", category.categoryName());
//![13]
}
{
//![14]
- QLoggingCategory category("qt.driver.usb");
+ QLoggingCategory category("driver.usb");
qCWarning(category, "a warning message logged into category %s", category.categoryName());
//![14]
}
{
//![15]
- QLoggingCategory category("qt.driver.usb");
+ QLoggingCategory category("driver.usb");
qCCritical(category, "a critical message logged into category %s", category.categoryName());
//![15]
}