Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. CuteLogger iostream confusion [Solved]
Qt 6.11 is out! See what's new in the release blog

CuteLogger iostream confusion [Solved]

Scheduled Pinned Locked Moved C++ Gurus
6 Posts 2 Posters 3.9k Views 1 Watching
  • 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.
  • G Offline
    G Offline
    GregWilsonLindberg
    wrote on last edited by
    #1

    Hi, is anyone using CuteLogger?

    I've got a problem/confusion with it and I can't find anywhere else to ask a question.

    If I use a embedded text line:

    LOG_INFO("Starting the application");
    

    everything is output in the way that I would expect. If I us an iostream with just a quoted string the output is as I would expect:

    LOG_INFO() << "Starting the application";
    

    But if I use a QString to output the text:

    LOG_INFO() << QString("Power On");
    

    I get the quotes included in the output:

    "Power On"
    

    instead of:
    Power On

    Does anyone have any experience with this or any insight into what is going on? I've tried these combinations with a QTextStream(stdout) iostream and I don't get the quotes so it appears to be something involving the CuteLogger, but I'm not enough of a C++ guru to know what might be happening.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      It's the normal behavior of QString when streamed to through qDebug, it outputs its content quoted.

      IIRC, there was something about a newly added option for that during the Categorized Logging presentation but I can't remember exactly how. Need to wait for the presentation to be published :)

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • G Offline
        G Offline
        GregWilsonLindberg
        wrote on last edited by
        #3

        I'm using this under Qt 4.8 so I guess that means that I will just have to live with it for now.

        Thanks for the update.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          You can surround your QString with qPrintable like this:

          @qDebug() << qPrintable(QString("Test"));@

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • G Offline
            G Offline
            GregWilsonLindberg
            wrote on last edited by
            #5

            Thank you, that seems to do exactly what I need.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              You're welcome !

              Since have pretty printing now, please update the thread title prepending [solved] so other forum users may know a solution has been found :)

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0

              • Login

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