Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-141457

Unclear remark about LoggingCategory performance issues

XMLWordPrintable

      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
          }
      }
      
      

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            qtqmlteam Qt Qml Team User
            kelteseth Elias Steurer
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:

                There are no open Gerrit changes