LoggingCategory QML Type
QML におけるロギングカテゴリを定義します。詳細...
| Import Statement: | import QtQml |
プロパティ
- defaultLogLevel : enumeration
- name : string
詳細な説明
コンソールログ関数(console.log() など)には、最初の引数としてロギングカテゴリを渡すことができます。ロガーに指定された場合、その 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 のみが出力されます。defaultLogLevel により、log message は抑制されます。ただし、QLoggingCategory と同様に、QMLロギングカテゴリのログレベルを設定することも可能です。
注: オブジェクトの生成にはコストがかかるため 、必要な LoggingCategory の定義をシングルトンにまとめ、必要な場所でこれをインポートすることを推奨します。
QLoggingCategoryも参照してください 。
プロパティのドキュメント
defaultLogLevel : enumeration
ロギングカテゴリのデフォルトのログレベルを保持します。デフォルトでは、LoggingCategory の「Debug」ログレベルで作成されます。
以下の列挙値が利用可能です:
- LoggingCategory.Debug
- LoggingCategory.Info
- LoggingCategory.Warning
- LoggingCategory.Critical
- LoggingCategory.Fatal
これらは、QtMsgType 列挙型の値を反映しています。
注: この プロパティは、LoggingCategory を宣言する際に設定する必要があり、後から変更することはできません。
「QtMsgType」も参照してください 。
name : string
ロギングカテゴリの名前を保持します。
注:この プロパティは、LoggingCategory を宣言する際に設定する必要があり、後から変更することはできません。
QLoggingCategory::categoryName()も参照してください 。
© 2026 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.