-
Task
-
Resolution: Unresolved
-
P3: Somewhat important
-
6.10.0
-
None
The docs state:
> 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.
but do not provide an example. I created this for my app:
pragma Singleton import QtQml /*! \qmltype LoggingCategories \brief Singleton containing all QML logging categories. This singleton provides centralized logging categories for the entire application. Using a singleton is more efficient than creating LoggingCategory objects in each component. \note Always use this singleton instead of creating local LoggingCategory instances. Example usage: \qml import ScreenPlay Item { Component.onCompleted: { console.log(LoggingCategories.monitorSelection, "Monitor selected") console.warn(LoggingCategories.timeline, "Timeline warning") } } \endqml */ QtObject { id: root readonly property LoggingCategory monitorSelection: LoggingCategory { name: "MonitorSelection" defaultLogLevel: LoggingCategory.Debug } readonly property LoggingCategory timeline: LoggingCategory { name: "timeline" defaultLogLevel: LoggingCategory.Debug } }