We have moved to a new Sailfish OS Forum. Please start new discussions there.
3

QT_NO_DEBUG_OUTPUT doesn't silence QML console.debug()

asked 2020-03-21 13:10:43 +0200

Direc gravatar image

Hi,

I am trying to control when qDebug() and console.debug() print their output to console, and it looks like a simple DEFINES += QT_NO_DEBUG_OUTPUT is not enough. It does silence qDebug(), but console.debug() still prints to console, both on devices and SDK. In order to silence console.debug() output, I have to do the following in the main() function

// [...]
#ifdef QT_NO_DEBUG_OUTPUT
#include <QLoggingCategory>
#endif

int main(int argc, char *argv[])
{
#ifdef QT_NO_DEBUG_OUTPUT
    // Disable QML debug level logging
    QLoggingCategory::setFilterRules("*.debug=false");
#endif
    // [...]
}

I don't find anything obvious in my .pro file, perhaps it comes from deeper somewhere? Should QT_NO_DEBUG_OUTPUT have that effect in the first place?

I am using Sailfish Application SDK 3.0.7, and I tested this in the emulator, and with my Jolla Phone and Sony Xperia Z3 Compact Tablet running SFOS 3.2.1, too.

If nothing else, I hope this helps others, should they run into the same issue.

Thanks!

edit retag flag offensive close delete

2 Answers

Sort by » oldest newest most voted
0

answered 2020-03-21 23:08:45 +0200

coderus gravatar image

https://forum.qt.io/topic/100098/how-i-can-disable-qdebug-and-console-log-logs-in-final-release/5

edit flag offensive delete publish link more

Comments

Thanks, but that takes care of log messages too. I only wanted to silence debug messages.

Direc ( 2020-03-22 00:04:50 +0200 )edit

what if you do qml.debug=false?

coderus ( 2020-03-22 02:03:50 +0200 )edit

That does work.

Thanks about the link; I ended up rethinking the whole thing and not got better grip at the whole logging system.

Direc ( 2020-03-23 08:43:14 +0200 )edit

Actually I dropped QT_NO_DEBUG_OUTPUT altogether and just use the method in the link to control the output - but it doesn't affect the issue.

Direc ( 2020-03-23 08:44:51 +0200 )edit

so what messages you want to silent? console.log produce debug output https://code.woboq.org/qt5/qtdeclarative/src/qml/qml/v8/qqmlbuiltinfunctions.cpp.html#1597

coderus ( 2020-03-23 18:03:25 +0200 )edit
0

answered 2020-03-23 09:43:09 +0200

martyone gravatar image

According to https://doc.qt.io/qt-5/debug.html#warning-and-debugging-messages

qDebug(), qInfo(), and qWarning() are debugging tools. They can be compiled away by defining QT_NO_DEBUG_OUTPUT, QT_NO_INFO_OUTPUT, or QT_NO_WARNING_OUTPUT during compilation.

So QT_NO_DEBUG_OUTPUT would have to be defined during the Qt QML module compilation to take the desired effect.

Sure it would be possible for Qt to make it work the way you expect, but at the same time it is no surprise that it does not work that way.

edit flag offensive delete publish link more
Login/Signup to Answer

Question tools

Follow
2 followers

Stats

Asked: 2020-03-21 13:10:43 +0200

Seen: 3,516 times

Last updated: Mar 23 '20