console application, how to write on stderr or stdout in release mode without qDebug logs?
-
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 .proI'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?
-
@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
-
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()
-
@mbruel Documentation has the answer: http://doc.qt.io/qt-5/qtglobal.html#qCritical