summaryrefslogtreecommitdiffstats
path: root/src/corelib/global/qglobal.cpp
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 /src/corelib/global/qglobal.cpp
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 'src/corelib/global/qglobal.cpp')
-rw-r--r--src/corelib/global/qglobal.cpp66
1 files changed, 53 insertions, 13 deletions
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 5206a038c8..e817b05243 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.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).
** Copyright (C) 2014 Intel Corporation
** Contact: http://www.qt-project.org/legal
**
@@ -547,9 +547,9 @@ Q_STATIC_ASSERT_X(UCHAR_MAX == 255, "Qt assumes that char is 8 bits");
\snippet code/src_corelib_global_qglobal.cpp 3
<QtGlobal> also contains functions that generate messages from the
- given string argument: qCritical(), qDebug(), qFatal() and
- qWarning(). These functions call the message handler with the
- given message.
+ given string argument: qDebug(), qInfo(), qWarning(), qCritical(),
+ and qFatal(). These functions call the message handler
+ with the given message.
Example:
@@ -768,6 +768,8 @@ Q_STATIC_ASSERT_X(UCHAR_MAX == 255, "Qt assumes that char is 8 bits");
\value QtDebugMsg
A message generated by the qDebug() function.
+ \value QtInfoMsg
+ A message generated by the qInfo() function.
\value QtWarningMsg
A message generated by the qWarning() function.
\value QtCriticalMsg
@@ -776,6 +778,7 @@ Q_STATIC_ASSERT_X(UCHAR_MAX == 255, "Qt assumes that char is 8 bits");
A message generated by the qFatal() function.
\value QtSystemMsg
+ \c QtInfoMsg was added in Qt 5.5.
\sa QtMessageHandler, qInstallMessageHandler()
*/
@@ -3539,8 +3542,8 @@ int qrand()
qPrintable() is used. This is because the array returned by
QString::toLocal8Bit() will fall out of scope.
- \note qDebug(), qWarning(), qCritical(), qFatal() expect %s
- arguments to be UTF-8 encoded, while qPrintable() converts to
+ \note qDebug(), qInfo(), qWarning(), qCritical(), qFatal() expect
+ %s arguments to be UTF-8 encoded, while qPrintable() converts to
local 8-bit encoding. Therefore qUtf8Printable() should be used
for logging strings instead of qPrintable().
@@ -3563,7 +3566,7 @@ int qrand()
\snippet code/src_corelib_global_qglobal.cpp 37
- \sa qPrintable(), qDebug(), qWarning(), qCritical(), qFatal()
+ \sa qPrintable(), qDebug(), qInfo(), qWarning(), qCritical(), qFatal()
*/
/*!
@@ -3974,8 +3977,8 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters)
Calls the message handler with the debug message \a message. If no
message handler has been installed, the message is printed to
- stderr. Under Windows, the message is sent to the console, if it is a
- console application; otherwise, it is sent to the debugger. On Blackberry the
+ stderr. Under Windows the message is sent to the console, if it is a
+ console application; otherwise, it is sent to the debugger. On Blackberry, the
message is sent to slogger2. This function does nothing if \c QT_NO_DEBUG_OUTPUT
was defined during compilation.
@@ -4000,7 +4003,44 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters)
To suppress the output at run-time, install your own message handler
with qInstallMessageHandler().
- \sa qWarning(), qCritical(), qFatal(), qInstallMessageHandler(),
+ \sa qInfo(), qWarning(), qCritical(), qFatal(), qInstallMessageHandler(),
+ {Debugging Techniques}
+*/
+
+/*!
+ \macro qInfo(const char *message, ...)
+ \relates <QtGlobal>
+ \since 5.5
+
+ Calls the message handler with the informational message \a message. If no
+ message handler has been installed, the message is printed to
+ stderr. Under Windows, the message is sent to the console, if it is a
+ console application; otherwise, it is sent to the debugger. On Blackberry the
+ message is sent to slogger2. This function does nothing if \c QT_NO_INFO_OUTPUT
+ was defined during compilation.
+
+ If you pass the function a format string and a list of arguments,
+ it works in similar way to the C printf() function. The format
+ should be a Latin-1 string.
+
+ Example:
+
+ \snippet code/src_corelib_global_qglobal.cpp qInfo_printf
+
+ If you include \c <QtDebug>, a more convenient syntax is also
+ available:
+
+ \snippet code/src_corelib_global_qglobal.cpp qInfo_stream
+
+ With this syntax, the function returns a QDebug object that is
+ configured to use the QtInfoMsg message type. It automatically
+ puts a single space between each item, and outputs a newline at
+ the end. It supports many C++ and Qt types.
+
+ To suppress the output at run-time, install your own message handler
+ with qInstallMessageHandler().
+
+ \sa qDebug(), qWarning(), qCritical(), qFatal(), qInstallMessageHandler(),
{Debugging Techniques}
*/
@@ -4034,7 +4074,7 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters)
To suppress the output at runtime, install your own message handler
with qInstallMessageHandler().
- \sa qDebug(), qCritical(), qFatal(), qInstallMessageHandler(),
+ \sa qDebug(), qInfo(), qCritical(), qFatal(), qInstallMessageHandler(),
{Debugging Techniques}
*/
@@ -4067,7 +4107,7 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters)
To suppress the output at runtime, install your own message handler
with qInstallMessageHandler().
- \sa qDebug(), qWarning(), qFatal(), qInstallMessageHandler(),
+ \sa qDebug(), qInfo(), qWarning(), qFatal(), qInstallMessageHandler(),
{Debugging Techniques}
*/
@@ -4094,7 +4134,7 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters)
To suppress the output at runtime, install your own message handler
with qInstallMessageHandler().
- \sa qDebug(), qCritical(), qWarning(), qInstallMessageHandler(),
+ \sa qDebug(), qInfo(), qWarning(), qCritical(), qInstallMessageHandler(),
{Debugging Techniques}
*/