From ef6279fd516befc09d4a6b3664a727a013b82c19 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Thu, 4 Dec 2014 16:57:32 +0100 Subject: 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 --- .../doc/snippets/code/src_corelib_global_qglobal.cpp | 13 ++++++++++++- src/corelib/doc/snippets/qloggingcategory/main.cpp | 14 +++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) (limited to 'src/corelib/doc') diff --git a/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp b/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp index d804514584..0ddd433d71 100644 --- a/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 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 documentation of the Qt Toolkit. @@ -253,6 +253,9 @@ void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QS case QtDebugMsg: fprintf(stderr, "Debug: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function); break; + case QtInfoMsg: + fprintf(stderr, "Info: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function); + break; case QtWarningMsg: fprintf(stderr, "Warning: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function); break; @@ -285,6 +288,14 @@ qDebug() << "Brush:" << myQBrush << "Other value:" << i; //! [25] +//! [qInfo_printf] +qInfo("Items in list: %d", myList.size()); +//! [qInfo_printf] + +//! [qInfo_stream] +qInfo() << "Brush:" << myQBrush << "Other value:" << i; +//! [qInfo_stream] + //! [26] void f(int c) { diff --git a/src/corelib/doc/snippets/qloggingcategory/main.cpp b/src/corelib/doc/snippets/qloggingcategory/main.cpp index 3c6424921e..504a88b1a8 100644 --- a/src/corelib/doc/snippets/qloggingcategory/main.cpp +++ b/src/corelib/doc/snippets/qloggingcategory/main.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 examples of the Qt Toolkit. @@ -117,6 +117,11 @@ oldCategoryFilter = QLoggingCategory::installFilter(myCategoryFilter); //![10] } +//![qcinfo_stream] + QLoggingCategory category("driver.usb"); + qCInfo(category) << "an informational message"; +//![qcinfo_stream] + { //![11] QLoggingCategory category("driver.usb"); @@ -138,6 +143,13 @@ oldCategoryFilter = QLoggingCategory::installFilter(myCategoryFilter); //![13] } + { +//![qcinfo_printf] + QLoggingCategory category("driver.usb"); + qCInfo(category, "an informational message logged into category %s", category.categoryName()); +//![qcinfo_printf] + } + { //![14] QLoggingCategory category("driver.usb"); -- cgit v1.2.3