Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QLoggingCategory - get default rules?

QLoggingCategory - get default rules?

Scheduled Pinned Locked Moved Solved General and Desktop
qloggingcategor
6 Posts 3 Posters 1.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dariusz
    wrote on last edited by Dariusz
    #1

    Hey

    How can I get default rules from qt loging ?

    When I do something like this >

        QLoggingCategory::setFilterRules(""
                      "*.debug=true\n"
                      "*.critical=true\n"
                      "*.warning=true\n"
                      "*.info=true\n"
                      "");
    

    I get a LOT more print than I usually get. So I'd like to see what other things gets logged so I can control it a little better.
    TIA!

    jeremy_kJ 1 Reply Last reply
    0
    • D Dariusz

      @KH-219Design Thanks lots! Whoa there is lots of tags O_O. But... how do I get the currently enabled tags? Is there a way to retrieve the list?
      I know that not everything gets printed as if I do *.debug=true/etc/etc I get more prints. So I wonder if there is a path for that? Or all get set up dynamically?

      jeremy_kJ Offline
      jeremy_kJ Offline
      jeremy_k
      wrote on last edited by
      #6

      @Dariusz That's what the QLoggingCategory::installFilter function lets you do.

      #include <QApplication>
      #include <QLoggingCategory>
      #include <QLabel>
      #include <cstdio>
      
       QLoggingCategory::CategoryFilter oldFilter;
      
      void myCategoryFilter(QLoggingCategory *category)
      {
          printf("pre-filter  %s: debug:%d info:%d warning:%d critical:%d\n",
                 category->categoryName(),
                 category->isDebugEnabled(),
                 category->isInfoEnabled(),
                 category->isWarningEnabled(),
                 category->isCriticalEnabled());
          if (oldFilter) {
              oldFilter(category);
              printf("post-filter %s: debug:%d info:%d warning:%d critical:%d\n",
                     category->categoryName(),
                     category->isDebugEnabled(),
                     category->isInfoEnabled(),
                     category->isWarningEnabled(),
                     category->isCriticalEnabled());
          }
          fflush(stdout);
      }
      
      int main(int argc, char *argv[])
      {
          oldFilter = QLoggingCategory::installFilter(myCategoryFilter);
          // Use some Qt functionality to cause categories to be registered
          QApplication a(argc, argv);
          QLabel label("text");
          label.show();
          return a.exec();
      }
      

      Sample ouput:

      pre-filter  qt.qpa: debug:1 info:1 warning:1 critical:1
      post-filter qt.qpa: debug:0 info:0 warning:1 critical:1
      pre-filter  qt.qpa.screen: debug:1 info:1 warning:1 critical:1
      post-filter qt.qpa.screen: debug:0 info:0 warning:0 critical:1
      pre-filter  qt.accessibility.cache: debug:1 info:1 warning:1 critical:1
      post-filter qt.accessibility.cache: debug:0 info:1 warning:1 critical:1
      ...
      

      Asking a question about code? http://eel.is/iso-c++/testcase/

      1 Reply Last reply
      3
      • D Dariusz

        Hey

        How can I get default rules from qt loging ?

        When I do something like this >

            QLoggingCategory::setFilterRules(""
                          "*.debug=true\n"
                          "*.critical=true\n"
                          "*.warning=true\n"
                          "*.info=true\n"
                          "");
        

        I get a LOT more print than I usually get. So I'd like to see what other things gets logged so I can control it a little better.
        TIA!

        jeremy_kJ Offline
        jeremy_kJ Offline
        jeremy_k
        wrote on last edited by
        #2

        QLoggingCategory::installFilter() looks like it can handle this.

        For each category passed into the filter:

        1. Call QLoggingCategory::isCriticalEnabled, isDebugEnabled, etc for the source code configuration.
        2. Call the initially installed filter
        3. Call isCriticalEnabled, etc for the configuration file and environment variable configuration

        Asking a question about code? http://eel.is/iso-c++/testcase/

        1 Reply Last reply
        0
        • KH-219DesignK Offline
          KH-219DesignK Offline
          KH-219Design
          wrote on last edited by
          #3

          I'm not sure I'm interpreting the thrust of the question correctly.

          Nevertheless...

          I think part of the question is how to basically figure out an exhaustive list of what is being enabled by using the snippet of code:

              QLoggingCategory::setFilterRules(""
                            "*.debug=true\n"
                            "*.critical=true\n"
                            "*.warning=true\n"
                            "*.info=true\n"
                            "");
          

          As you said, it is indeed a LOT.

          The first thing I thought of in terms of figuring out what the deluge consists of...

          ... I navigated to where I keep a copy of the source code to the whole Qt framework itself, and ran this:

          # in a bash terminal:
          
          grep -rwh Q_LOGGING_CATEGORY | grep '"qt\.' | sort | uniq | awk -F\" '{print $2}' | sort | uniq
          

          This produces a list of 230 logging categories internal to Qt itself.

          However, even this list of 230 categories is not exhaustive, because I have not cloned 100% of the framework, but rather only certain modules (including qtbase, qtdeclarative, and a handful of others).

          I will post the list in a separate message (right after this one). Hopefully the forum software will put scrollbars around it.

          Because Qt is consistent in naming its categories with the prefix qt., you can enable all of your own logging categories but none from Qt by doing something like this before launching the program:

          export QT_LOGGING_RULES="*=true;qt*=false;"
          

          www.219design.com
          Software | Electrical | Mechanical | Product Design

          1 Reply Last reply
          2
          • KH-219DesignK Offline
            KH-219DesignK Offline
            KH-219Design
            wrote on last edited by
            #4

            the output of my bash expression:

            qt.accessibility.atspi
            qt.accessibility.atspi.creation
            qt.accessibility.cache
            qt.accessibility.core
            qt.bluetooth
            qt.bluetooth.android
            qt.bluetooth.bluez
            qt.bluetooth.ios
            qt.bluetooth.osx
            qt.bluetooth.qml
            qt.bluetooth.windows
            qt.bluetooth.winrt
            qt.bluetooth.winrt.service.thread
            qt.corecon
            qt.core.filesystemwatcher
            qt.corelib.tests.itemmodels
            qt.core.qabstractitemmodel.checkindex
            qt.core.qmetaobject.connectslotsbyname
            qt.core.socketnotifier_deprecation
            qt.distanceField
            qt.egl.xlib.debug
            qt.eventdispatcher
            qt.eventdispatcher.activity
            qt.eventdispatcher.timers
            qt.examples.imagegestures
            qt.examples.pdfviewer
            qt.gifrecorder
            qt.glx
            qt.gui.dnd
            qt.gui.drawhelper
            qt.gui.icc
            qt.gui.shortcutmap
            qt.gui.textureio
            qt.imageformat.pdf
            qt.labs.platform.dialogs
            qt.labs.platform.menus
            qt.labs.platform.tray
            qt.labs.settings
            qt.mm.camera
            qt.mm.videorender
            qt.modeltest
            qt.multimedia.alsa.output
            qt.multimedia.audioinput
            qt.multimedia.audiointerface
            qt.multimedia.audiooutput
            qt.multimedia.deviceinfo
            qt.multimedia.plugin
            qt.multimedia.plugins.android
            qt.multimedia.plugins.directshow
            qt.multimedia.plugins.directshow.renderfilter
            qt.multimedia.utils
            qt.multimedia.video
            qt.network.http2
            qt.network.monitor
            qt.network.socket
            qt.network.socket.verbose
            qt.network.ssl
            qt.nfc.neard
            qt.opengl.diskcache
            qt.pdf.document
            qt.pdf.links
            qt.pdf.navigationstack
            qt.pdf.search
            qt.positioning.geoclue
            qt.positioning.geoclue2
            qt.positioning.serialnmea
            qt.positioning.winrt
            qt.qdoc
            qt.qml.binding.removal
            qt.qml.diskcache
            qt.qml.gc.allocatorStats
            qt.qml.gc.statistics
            qt.qml.tablemodel
            qt.qpa
            qt.qpa.accessibility
            qt.qpa.application
            qt.qpa.backingstore
            qt.qpa.backingstore.iosurface
            qt.qpa.clipboard
            qt.qpa.cocoa.notifications
            qt.qpa.dialogs
            qt.qpa.drawing
            qt.qpa.egldeviceintegration
            qt.qpa.eglfs.kms
            qt.qpa.events
            qt.qpa.events.reader
            qt.qpa.fb
            qt.qpa.fonts
            qt.qpa.gl
            qt.qpa.glcontext
            qt.qpa.input
            qt.qpa.input.devices
            qt.qpa.input.events
            qt.qpa.input.gestures
            qt.qpa.input.keymap
            qt.qpa.input.methods
            qt.qpa.input.methods.serialize
            qt.qpa.input.mouse
            qt.qpa.input.tablet
            qt.qpa.input.touch
            qt.qpa.menu
            qt.qpa.menus
            qt.qpa.mime
            qt.qpa.openglcontext
            qt.qpa.peeker
            qt.qpa.plugin
            qt.qpa.screen
            qt.qpa.screen.updates
            qt.qpa.theme
            qt.qpa.tray
            qt.qpa.trayicon
            qt.qpa.tuio.bundle
            qt.qpa.tuio.handler
            qt.qpa.tuio.message
            qt.qpa.tuio.set
            qt.qpa.tuio.source
            qt.qpa.uiautomation
            qt.qpa.vnc
            qt.qpa.wayland
            qt.qpa.wayland.backingstore
            qt.qpa.wayland.input
            qt.qpa.window
            qt.qpa.windows
            qt.qpa.xcb
            qt.qpa.xdnd
            qt.qpa.xkeyboard
            qt.quick.boundaryrule
            qt.quick.canvas
            qt.quick.controls.control.itemmanagement
            qt.quick.controls.imagine
            qt.quick.controls.splitview
            qt.quick.controls.splitview.mouse
            qt.quick.controls.splitview.state
            qt.quick.controls.style
            qt.quick.controls.tools.testbench.assetfixer.brief
            qt.quick.controls.tools.testbench.assetfixer.verbose
            qt.quick.controls.tumbler
            qt.quick.controls.tumblerview
            qt.quick.dialogs.registration
            qt.quick.dialogs.window
            qt.quick.dirty
            qt.quick.focus
            qt.quick.gesture.target
            qt.quick.handler.active
            qt.quick.handler.dispatch
            qt.quick.handler.drag
            qt.quick.handler.grab
            qt.quick.handler.hover
            qt.quick.handler.parent
            qt.quick.handler.pinch
            qt.quick.handler.tap
            qt.quick.handler.wheel
            qt.quick.hover.trace
            qt.quick.image
            qt.quick.itemview.delegaterecycling
            qt.quick.itemview.lifecycle
            qt.quick.mouse
            qt.quick.mouse.target
            qt.quick.pathview
            qt.quick.pointer.events
            qt.quick.pointer.grab
            qt.quick.pointer.tests
            qt.quick.sharedimage
            qt.quick.tablet
            qt.quick.tableview.lifecycle
            qt.quick.tests
            qt.quick.touch
            qt.quick.touch.target
            qt.quick.wheel.target
            qt.quick.window.transient
            qt.rhi.general
            qt.scaling
            qt.scenegraph.general
            qt.scenegraph.info
            qt.scenegraph.renderloop
            qt.scenegraph.softwarecontext.abstractrenderer
            qt.scenegraph.softwarecontext.pixmapRenderer
            qt.scenegraph.softwarecontext.renderable
            qt.scenegraph.softwarecontext.renderer
            qt.scenegraph.textureio
            qt.scenegraph.time.compilation
            qt.scenegraph.time.glyph
            qt.scenegraph.time.renderer
            qt.scenegraph.time.renderloop
            qt.scenegraph.time.texture
            qt.shape.time.sync
            qt.speech.tts.android
            qt.speech.tts.flite
            qt.svg
            qt.svg.draw
            qt.test
            qt.text.browser
            qt.text.drawing
            qt.text.font.db
            qt.text.font.match
            qt.text.hittest
            qt.text.layout
            qt.text.layout.table
            qt.text.markdown
            qt.text.markdown.writer
            qt.text.tests
            qt.v4.asm
            qt.virtualkeyboard
            qt.virtualkeyboard.hunspell
            qt.virtualkeyboard.lipi
            qt.virtualkeyboard.myscript
            qt.virtualkeyboard.openwnn
            qt.virtualkeyboard.pinyin
            qt.virtualkeyboard.t9write
            qt.virtualkeyboard.tcime
            qt.virtualkeyboard.tests.manual.x11vkbtest.filehelper
            qt.virtualkeyboard.tests.manual.x11vkbtest.memorymonitor
            qt.virtualkeyboard.tests.manual.x11vkbtest.testlanguagechange
            qt.virtualkeyboard.tests.manual.x11vkbtest.testthread
            qt.virtualkeyboard.tests.manual.x11vkbwrapper.handleatspievents
            qt.virtualkeyboard.tests.manual.x11vkbwrapper.handlekeyevents
            qt.virtualkeyboard.tests.manual.x11vkbwrapper.handlelanguagechange
            qt.vulkan
            qt.waylandcompositor
            qt.waylandcompositor.hardwareintegration
            qt.waylandcompositor.inputmethods
            qt.webengine.webchanneltransport
            qt.widgets.gestures
            qt.widgets.painting
            qt.widgets.tests
            qt.widgets.tests.qfilesystemmodel
            qt.winrtrunner
            qt.winrtrunner.app
            qt.xkbcommon
            qt.xkb.compose
            
            

            www.219design.com
            Software | Electrical | Mechanical | Product Design

            1 Reply Last reply
            1
            • D Offline
              D Offline
              Dariusz
              wrote on last edited by
              #5

              @KH-219Design Thanks lots! Whoa there is lots of tags O_O. But... how do I get the currently enabled tags? Is there a way to retrieve the list?
              I know that not everything gets printed as if I do *.debug=true/etc/etc I get more prints. So I wonder if there is a path for that? Or all get set up dynamically?

              jeremy_kJ 1 Reply Last reply
              0
              • D Dariusz

                @KH-219Design Thanks lots! Whoa there is lots of tags O_O. But... how do I get the currently enabled tags? Is there a way to retrieve the list?
                I know that not everything gets printed as if I do *.debug=true/etc/etc I get more prints. So I wonder if there is a path for that? Or all get set up dynamically?

                jeremy_kJ Offline
                jeremy_kJ Offline
                jeremy_k
                wrote on last edited by
                #6

                @Dariusz That's what the QLoggingCategory::installFilter function lets you do.

                #include <QApplication>
                #include <QLoggingCategory>
                #include <QLabel>
                #include <cstdio>
                
                 QLoggingCategory::CategoryFilter oldFilter;
                
                void myCategoryFilter(QLoggingCategory *category)
                {
                    printf("pre-filter  %s: debug:%d info:%d warning:%d critical:%d\n",
                           category->categoryName(),
                           category->isDebugEnabled(),
                           category->isInfoEnabled(),
                           category->isWarningEnabled(),
                           category->isCriticalEnabled());
                    if (oldFilter) {
                        oldFilter(category);
                        printf("post-filter %s: debug:%d info:%d warning:%d critical:%d\n",
                               category->categoryName(),
                               category->isDebugEnabled(),
                               category->isInfoEnabled(),
                               category->isWarningEnabled(),
                               category->isCriticalEnabled());
                    }
                    fflush(stdout);
                }
                
                int main(int argc, char *argv[])
                {
                    oldFilter = QLoggingCategory::installFilter(myCategoryFilter);
                    // Use some Qt functionality to cause categories to be registered
                    QApplication a(argc, argv);
                    QLabel label("text");
                    label.show();
                    return a.exec();
                }
                

                Sample ouput:

                pre-filter  qt.qpa: debug:1 info:1 warning:1 critical:1
                post-filter qt.qpa: debug:0 info:0 warning:1 critical:1
                pre-filter  qt.qpa.screen: debug:1 info:1 warning:1 critical:1
                post-filter qt.qpa.screen: debug:0 info:0 warning:0 critical:1
                pre-filter  qt.accessibility.cache: debug:1 info:1 warning:1 critical:1
                post-filter qt.accessibility.cache: debug:0 info:1 warning:1 critical:1
                ...
                

                Asking a question about code? http://eel.is/iso-c++/testcase/

                1 Reply Last reply
                3

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved