LoggingCategory QML Type▲
-
Import Statement: import QtQml
-
Group: LoggingCategory is part of qml-utility-elements
Detailed Description▲
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.
import
QtQuick
Item
{
LoggingCategory {
id
:
category
name
:
"com.qt.category"
defaultLogLevel
:
LoggingCategory.Warning
}
Component.onCompleted
: {
console.log
(
category,
"log message"
);
console.warn
(
category,
"warning message"
);
}
}
By default this outputs only com.qt.category: warning message. The log message is suppressed due to the defaultLogLevel. You can, however, configure log levels for QML logging categories the same way you can configure them for QLoggingCategory.
As the creation of objects is expensive, it is encouraged to put the needed LoggingCategory definitions into a singleton and import this where needed.
See Also▲
See also QLoggingCategory
Property Documentation▲
defaultLogLevel : enumeration▲
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:
-
LoggingCategory.Debug
-
LoggingCategory.Info
-
LoggingCategory.Warning
-
LoggingCategory.Critical
-
LoggingCategory.Fatal
They mirror the values of the QtMsgType enumeration.
This property needs to be set when declaring the LoggingCategory and cannot be changed later.
See Also▲
See also QtMsgType
name : string▲
Holds the name of the logging category.
This property needs to be set when declaring the LoggingCategory and cannot be changed later.
See Also▲
See also QLoggingCategory::categoryName()