LoggingCategory QML Type

Defines a logging category in QML. More...

Import Statement: import QtQml 2.12
Since: Qt 5.8

Properties

Detailed Description

A logging category can be passed to console.log() and friends as the first argument. If supplied to to the logger the LoggingCategory's name will be used as Logging Category otherwise the default logging category will be used.

import QtQuick 2.8

Item {
    LoggingCategory {
        id: category
        name: "com.qt.category"
        defaultLogLevel: LoggingCategory.Warning
    }

    Component.onCompleted: {
      console.log(category, "message");
    }
}

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.

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.

Note: This property needs to be set when declaring the LoggingCategory and cannot be changed later.

This property was introduced in Qt 5.12.

name : string

Holds the name of the logging category.

Note: This property needs to be set when declaring the LoggingCategory and cannot be changed later.

See also QLoggingCategory::categoryName().

© The Qt Company Ltd
Licensed under the GNU Free Documentation License, Version 1.3.
https://doc.qt.io/qt-5.12/qml-qtqml-loggingcategory.html