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. Capture specific logging output into a QString

Capture specific logging output into a QString

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 341 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.
  • A Offline
    A Offline
    Asperamanca
    wrote on 7 May 2021, 12:59 last edited by
    #1

    I enabled the following logging category to get some basic information about the scenegraph setup:
    `QLoggingCategory::setFilterRules("qt.scenegraph.general=true");
    This gives me an output like

    qt.scenegraph.general: opengl texture atlas dimensions: 512x512
    qt.scenegraph.general: R/G/B/A Buffers:   8 8 8 8
    qt.scenegraph.general: Depth Buffer:      24
    qt.scenegraph.general: Stencil Buffer:    8
    qt.scenegraph.general: Samples:           0
    qt.scenegraph.general: GL_VENDOR:         Google Inc.
    qt.scenegraph.general: GL_RENDERER:       ANGLE (Intel(R) UHD Graphics 630 Direct3D11 vs_5_0 ps_5_0)
    qt.scenegraph.general: GL_VERSION:        OpenGL ES 2.0 (ANGLE 2.1.0.57ea533f79a7)
    ...
    

    I'd like to redirect this output to a string, so I can add it to a diagnosis information file. However, the only way I know so far is to use qInstallMessageHandler, which would capture other debug messages as well.

    How can I selectively capture the scenegraph info, but not other debug messages?

    J 1 Reply Last reply 7 May 2021, 13:50
    0
    • A Asperamanca
      7 May 2021, 12:59

      I enabled the following logging category to get some basic information about the scenegraph setup:
      `QLoggingCategory::setFilterRules("qt.scenegraph.general=true");
      This gives me an output like

      qt.scenegraph.general: opengl texture atlas dimensions: 512x512
      qt.scenegraph.general: R/G/B/A Buffers:   8 8 8 8
      qt.scenegraph.general: Depth Buffer:      24
      qt.scenegraph.general: Stencil Buffer:    8
      qt.scenegraph.general: Samples:           0
      qt.scenegraph.general: GL_VENDOR:         Google Inc.
      qt.scenegraph.general: GL_RENDERER:       ANGLE (Intel(R) UHD Graphics 630 Direct3D11 vs_5_0 ps_5_0)
      qt.scenegraph.general: GL_VERSION:        OpenGL ES 2.0 (ANGLE 2.1.0.57ea533f79a7)
      ...
      

      I'd like to redirect this output to a string, so I can add it to a diagnosis information file. However, the only way I know so far is to use qInstallMessageHandler, which would capture other debug messages as well.

      How can I selectively capture the scenegraph info, but not other debug messages?

      J Offline
      J Offline
      JonB
      wrote on 7 May 2021, 13:50 last edited by
      #2

      @Asperamanca
      So far as I know: yes you use qInstallMessageHandler, use the QMessageLogContext to check the category name, do what you want with your category, call the old message handler for other stuff.

      A 1 Reply Last reply 10 May 2021, 06:47
      1
      • J JonB
        7 May 2021, 13:50

        @Asperamanca
        So far as I know: yes you use qInstallMessageHandler, use the QMessageLogContext to check the category name, do what you want with your category, call the old message handler for other stuff.

        A Offline
        A Offline
        Asperamanca
        wrote on 10 May 2021, 06:47 last edited by
        #3

        @JonB said in Capture specific logging output into a QString:

        QMessageLogContext

        According to Qt docs, QMessageLogContext does not have a public interface, and may only provide information in debug builds.

        J 1 Reply Last reply 10 May 2021, 08:12
        0
        • A Asperamanca
          10 May 2021, 06:47

          @JonB said in Capture specific logging output into a QString:

          QMessageLogContext

          According to Qt docs, QMessageLogContext does not have a public interface, and may only provide information in debug builds.

          J Offline
          J Offline
          JonB
          wrote on 10 May 2021, 08:12 last edited by
          #4

          @Asperamanca
          I did not test/look into it further, but I saw e.g. https://stackoverflow.com/questions/29646942/qmessagelogcontexts-fields-like-file-function-line-empty-or-zero

          void action(QtMsgType type, const QMessageLogContext &context, const QString &msg)
          {
                ts << context.file << ":" << context.line << ":"
                   << context.function << ": " << msg << endl;
          }
          

          so it seems to be accessing QMessageLogContext fields. The reply there talks about debug/release builds.

          Your documentation link is https://doc.qt.io/qt-5/qmessagelogcontext.html. But if you look at, say, https://doc-snapshots.qt.io/qt5-5.12/qmessagelogcontext.html you see the various fields described, including const char *category. That's all I know!

          1 Reply Last reply
          1

          1/4

          7 May 2021, 12:59

          • Login

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