aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2023-10-13 14:11:17 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-10-18 06:37:01 +0000
commit77b15b954c31dfa3452bdabf9262cb8bae2bdef2 (patch)
tree03c873dae6f3ddeb7eb2c89446365a672a23149b
parent5cdbe7517586ee123ccea67db7638e3e617c2aea (diff)
QtQml: Improve documentation of LoggingCategory
Explain the example some more, document the enum, fix some grammar problems. Fixes: QTBUG-96007 Change-Id: I5d113f198a95e514026e71334bd40851941d924a Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> (cherry picked from commit ad81532099284d4bb6eea8b24e6e5cd269695746) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit 31410611ec995a5ab658e8a9bc6716b634edbb5e)
-rw-r--r--src/qml/qml/qqmlloggingcategory.cpp28
1 files changed, 24 insertions, 4 deletions
diff --git a/src/qml/qml/qqmlloggingcategory.cpp b/src/qml/qml/qqmlloggingcategory.cpp
index 660d7cb9cf..8d7fd6c04d 100644
--- a/src/qml/qml/qqmlloggingcategory.cpp
+++ b/src/qml/qml/qqmlloggingcategory.cpp
@@ -15,11 +15,11 @@
\since 5.8
A logging category can be passed to console.log() and friends as the first argument.
- If supplied to the logger the LoggingCategory's name will be used as Logging Category
- otherwise the default logging category will be used.
+ If supplied to the logger the LoggingCategory's name will be used as logging category.
+ Otherwise the default logging category will be used.
\qml
- import QtQuick 2.8
+ import QtQuick
Item {
LoggingCategory {
@@ -29,11 +29,18 @@
}
Component.onCompleted: {
- console.log(category, "message");
+ console.log(category, "log message");
+ console.warn(category, "warning message");
}
}
\endqml
+ By default this outputs only \c{com.qt.category: warning message}. The
+ \c{log message} is suppressed due to the \l{defaultLogLevel}. You can,
+ however, configure log levels for QML logging categories the same way
+ you can configure them for
+ \l{QLoggingCategory#configuring-categories}{QLoggingCategory}.
+
\note As the creation of objects is expensive, it is encouraged to put the needed
LoggingCategory definitions into a singleton and import this where needed.
@@ -58,8 +65,21 @@
Holds the default log level of the logging category. By default it is
created with the LoggingCategory.Debug log level.
+ The following enumeration values are available:
+ \list
+ \li LoggingCategory.Debug
+ \li LoggingCategory.Info
+ \li LoggingCategory.Warning
+ \li LoggingCategory.Critical
+ \li LoggingCategory.Fatal
+ \endlist
+
+ They mirror the values of the \l{QtMsgType} enumeration.
+
\note This property needs to be set when declaring the LoggingCategory
and cannot be changed later.
+
+ \sa QtMsgType
*/
QQmlLoggingCategory::QQmlLoggingCategory(QObject *parent)