LoggingCategory QML Type

Defines a logging category in QML. 更多...

import 語句: import QtQml 2.15
Since: Qt 5.8

特性

詳細描述

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");
    }
}
					

注意: As the creation of objects is expensive, it is encouraged to put the needed LoggingCategory definitions into a singleton and import this where needed.

另請參閱 QLoggingCategory .

特性文檔編製

defaultLogLevel : enumeration

Holds the default log level of the logging category. By default it is created with the LoggingCategory .Debug log level.

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

該特性在 Qt 5.12 引入。

name : string

Holds the name of the logging category.

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

另請參閱 QLoggingCategory::categoryName() .