diff options
author | Kai Koehne <kai.koehne@digia.com> | 2014-01-09 15:38:17 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-01-21 14:58:03 +0100 |
commit | b8a38a6737acd670d92197ca5b009590d9fd8a9c (patch) | |
tree | 1b01d7a85a6f35cd420e3cef1bd50490988d7058 /src/corelib/io/qloggingcategory.cpp | |
parent | b152b425f74788b2f2845fb7d1a5032d86b8746d (diff) |
Allow printf style for qCDebug, qCWarning, qCCritical macros
Add support for using qCDebug and friends in the 'printf style' way.
This allows an almost mechanical conversion of existing qDebug, qWarning,
qCritical macros, and allows avoiding the size overhead the streaming
style incurs (mostly due to inlined QDebug code).
To handle this gracefully we require variadic macros (part of
C++11/C99). For compilers not supporting variadic macros we fall back
to checking the category in QMessageLogger.
[ChangeLog][QtCore][Logging] Allow qCDebug macros to be used in a printf
style.
Change-Id: I5a8fb135dca504e1d621bb67bf4b2a50c73d41b9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/io/qloggingcategory.cpp')
-rw-r--r-- | src/corelib/io/qloggingcategory.cpp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/corelib/io/qloggingcategory.cpp b/src/corelib/io/qloggingcategory.cpp index 93a98b1835..8c3ca5fd65 100644 --- a/src/corelib/io/qloggingcategory.cpp +++ b/src/corelib/io/qloggingcategory.cpp @@ -326,6 +326,25 @@ void QLoggingCategory::setFilterRules(const QString &rules) */ /*! + \macro qCDebug(category, const char *message, ...) + \relates QLoggingCategory + \since 5.3 + + Logs a debug message \a message in the logging category \a category. + \a message might contain place holders that are replaced by additional + arguments, similar to the C printf() function. + + Example: + + \snippet qloggingcategory/main.cpp 13 + + \note Arguments might not be processed if debug output for the category is + not enabled, so do not rely on any side effects. + + \sa qDebug() +*/ + +/*! \macro qCWarning(category) \relates QLoggingCategory \since 5.2 @@ -348,6 +367,25 @@ void QLoggingCategory::setFilterRules(const QString &rules) */ /*! + \macro qCWarning(category, const char *message, ...) + \relates QLoggingCategory + \since 5.3 + + Logs a warning message \a message in the logging category \a category. + \a message might contain place holders that are replaced by additional + arguments, similar to the C printf() function. + + Example: + + \snippet qloggingcategory/main.cpp 14 + + \note Arguments might not be processed if warning output for the category is + not enabled, so do not rely on any side effects. + + \sa qWarning() +*/ + +/*! \macro qCCritical(category) \relates QLoggingCategory \since 5.2 @@ -370,6 +408,24 @@ void QLoggingCategory::setFilterRules(const QString &rules) */ /*! + \macro qCCritical(category, const char *message, ...) + \relates QLoggingCategory + \since 5.3 + + Logs a critical message \a message in the logging category \a category. + \a message might contain place holders that are replaced by additional + arguments, similar to the C printf() function. + + Example: + + \snippet qloggingcategory/main.cpp 15 + + \note Arguments might not be processed if critical output for the category + is not enabled, so do not rely on any side effects. + + \sa qCritical() +*/ +/*! \macro Q_DECLARE_LOGGING_CATEGORY(name) \relates QLoggingCategory \since 5.2 |