How can i toggle debug output *at runtime*?

My nickname is attah, and I’m a qDebug() addict.

Yes, it can be toggled at compile time, but for asking people for logs that is quite crap.
Do i really have to make my own qDebug shim to be able to turn it on and off at runtime?
The google results seems to say this, but there are lots of smart people here so i thought i should ask none the less.

Not an expert at all but doesn’t ~/.config/QtProject/qtlogging.ini control this?

Also, the QT_LOGGING_RULES environment variable?

Exactly, when you create file ~/.config/QtProject/qtlogging.ini with this content:

[Rules]
*.debug=true
qt.*.debug=false

it will turn on debug logging for all applications, when you switch even qt.*.debug to true, it will enable debug messages from Qt internal classes, you will see huge noise from QML components…

It seems that QT_LOGGING_RULES has no effect with Qt 5.6 used on Sailfish OS. Beside debug toggle, you may control format of log messages by environment variable QT_MESSAGE_PATTERN. It is nicely described on this post: Nicer debug output in Qt using QT_MESSAGE_PATTERN I really like the usage of red color for warning messages :wink:

1 Like

@nephros , @karry Interesting; that instinctively felt compile-time too, but i see now i was mistaken.
However; that will apply to all applications, right?
I’m more after something for just my application, and that i can tell users to enable if they have problems.

But none the less, thanks for educating me.

If you look in ~/.config/QtProject/ you may see profiles for specific applications. Or can create some.

Like https://jolla.zendesk.com/hc/en-us/articles/201975906-How-to-take-Email-logs-General-email-IMAP-POP- and parts of Sailfish OS Cheat Sheet | Sailfish OS Documentation describe.

3 Likes