LoggingCategory QML Type

QMLでロギングカテゴリを定義します。詳細...

Import Statement: import QtQml

プロパティ

詳細説明

ロギングカテゴリは、console.log() と friends に最初の引数として渡すことができます。ロガーに渡された場合、LoggingCategory の名前がロギングカテゴリーとして使用されます。そうでなければ、デフォルトのロギング・カテゴリーが使用されます。

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

デフォルトでは、com.qt.category: warning message のみが出力されます。log messagedefaultLogLevel のために抑制されます。 しかし、QLoggingCategory と同じように、QMLのロギングカテゴリーに対してもログレベルを設定することができます。

注意: オブジェクトの生成にはコストがかかるので、必要な LoggingCategory の定義をシングルトンにして、必要な場所でインポートすることを推奨します。

QLoggingCategoryも参照してください

プロパティ ドキュメント

defaultLogLevel : enumeration

ロギングカテゴリのデフォルトのログレベルを保持します。デフォルトでは、LoggingCategory.Debug ログレベルで作成されます。

以下の列挙値を使用できます:

これらは、QtMsgType 列挙の値を反映している。

注意: このプロパティはLoggingCategory を宣言するときに設定する必要があり、後で変更することはできません。

QtMsgTypeも参照のこと


name : string

ロギング・カテゴリの名前を保持する。

注意: このプロパティはLoggingCategory を宣言するときに設定する必要があり、後で変更することはできません。

QLoggingCategory::categoryName()も参照して ください。


© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.