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. console application, how to write on stderr or stdout in release mode without qDebug logs?
Forum Updated to NodeBB v4.3 + New Features

console application, how to write on stderr or stdout in release mode without qDebug logs?

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 3.0k 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.
  • mbruelM Offline
    mbruelM Offline
    mbruel
    wrote on last edited by
    #1

    Hi,
    I'm doing a console application that takes in input a configuration file to load several things prior to do its computation.
    I'd like to write an error message on stderr or stdout when some inputs are wrong before exiting.
    I'm thus writing on a QTextStream(stderr) or QTextStream(stdout) and I'm not seeing my messages on Windows 10 console.
    I had "CONFIG -= console" on my .pro

    I've put back "CONFIG += console" in the .pro. I now see my error message prior to exit BUT I also see all the qDebug statements.

    I thought qDebug logs where ignored (even maybe not compiled) in Release mode. Is it not the case?

    How can I not show my debug logs and only write error messages?

    1 Reply Last reply
    0
    • Gojir4G Offline
      Gojir4G Offline
      Gojir4
      wrote on last edited by Gojir4
      #2

      @mbruel said in console application, how to write on stderr or stdout in release mode without qDebug logs?:

      I thought qDebug logs where ignored (even maybe not compiled) in Release mode. Is it not the case?

      I was thinking the same, but no, it's not the case.

      @mbruel said in console application, how to write on stderr or stdout in release mode without qDebug logs?:

      How can I not show my debug logs and only write error messages?

      You can add this into you .pro file to disable debug output in release mode:

      #No debug output in release mode
      CONFIG(release, debug|release): DEFINES += QT_NO_DEBUG_OUTPUT
      
      mbruelM 1 Reply Last reply
      5
      • Gojir4G Gojir4

        @mbruel said in console application, how to write on stderr or stdout in release mode without qDebug logs?:

        I thought qDebug logs where ignored (even maybe not compiled) in Release mode. Is it not the case?

        I was thinking the same, but no, it's not the case.

        @mbruel said in console application, how to write on stderr or stdout in release mode without qDebug logs?:

        How can I not show my debug logs and only write error messages?

        You can add this into you .pro file to disable debug output in release mode:

        #No debug output in release mode
        CONFIG(release, debug|release): DEFINES += QT_NO_DEBUG_OUTPUT
        
        mbruelM Offline
        mbruelM Offline
        mbruel
        wrote on last edited by
        #3

        @Gojir4
        Thanks, it is working.
        I've only used qDebug for now and just noticed that qCritical and qFatal exist.
        What's the difference between using those or directly writing on stderr?
        Cheers

        jsulmJ 1 Reply Last reply
        0
        • Gojir4G Offline
          Gojir4G Offline
          Gojir4
          wrote on last edited by
          #4

          I think qFatal() closes the application. But I don't know the difference with qDebug(), I'm using only this one.

          You can also implemented you own message hanlding by using qInstallMessageHandler()

          1 Reply Last reply
          0
          • mbruelM mbruel

            @Gojir4
            Thanks, it is working.
            I've only used qDebug for now and just noticed that qCritical and qFatal exist.
            What's the difference between using those or directly writing on stderr?
            Cheers

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @mbruel Documentation has the answer: http://doc.qt.io/qt-5/qtglobal.html#qCritical

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            mbruelM 1 Reply Last reply
            2
            • jsulmJ jsulm

              @mbruel Documentation has the answer: http://doc.qt.io/qt-5/qtglobal.html#qCritical

              mbruelM Offline
              mbruelM Offline
              mbruel
              wrote on last edited by
              #6

              @jsulm
              Indeed, it answers the question :)

              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