From 0fe2713e260c8ecfa463a7075a6b9f1892000691 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Fri, 11 Jul 2014 12:10:42 +0200 Subject: 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 Reviewed-by: Alex Blasche --- src/corelib/doc/snippets/qloggingcategory/main.cpp | 28 +++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'src/corelib/doc') 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] } -- cgit v1.2.3