PDA

View Full Version : Dual Output For qInstallMessageHandler



brixel
6th May 2016, 11:57
Hello,

I'm utilizing qInstallMessageHandler with a custom handler to control the format of the message output. This is working correctly. The issue is now that I'm intercepting the data and formatting it, it is no longer making it's way to the Windows debug view as it was prior this. I was using the code provided in the example here (http://doc.qt.io/qt-5/qtglobal.html#qInstallMessageHandler).

I then tried instead to push the data out this way:

QTextStream(stdout)

Passing in the various arguments, which again, works for the IDE but not when running natively and looking to see debug data in the Windows debug view. Is there anyway to have this handler so I can keep messages in the IDE, but also allow for them to be viewed in Windows debug view?

anda_skoa
6th May 2016, 12:40
Have you tried writing to stderr?

Also have a look at this https://woboq.com/blog/nice-debug-output-with-qt.html for a built-in option on customiing the log output.

Cheers,
_

brixel
6th May 2016, 12:52
Yeah, I tried stderr as that was what they show in the example but it didn't make a difference. I'll have a look at your link.

Had a look at the link and that is really cool. The only issue is that outside of just altering the look of the message, I need to make certain types conditional and I don't see how you can do that through the pattern QT_MESSAGE_PATTERN.

anda_skoa
6th May 2016, 13:33
After a bit of digging I found this:
https://code.woboq.org/qt5/qtbase/src/corelib/global/qlogging.cpp.html#_ZL22qDefaultMessageHandler9QtMs gTypeRK18QMessageLogContextRK7QString

Seems the Windows specific code paths of the default message handler uses some Windows API for logging instead of writing to any IO stream.

Cheers,
_

brixel
6th May 2016, 14:31
Ah - Yes, OutputDebugString. I'll have to try and figure out how to use that. Thanks for finding this.