Writing debug information both in file and Windows debugger
Good day, colleagues!
How could I write debug info both to custom place (e. g. in file) and to default location (e. g. Windows debug console)?
Currently I use qInstallMsgHandler with this handler:
- void My_Message_Handler (QtMsgType message_type, const char * message) {
- QString debug_string;
- switch (message_type) {
- break;
- ...
- text_stream << debug_string << '\n';
- }
What should I add to my code to write to the default debug output too?
4 replies
Easiest way is to use a different logger than Qt’s. QxtLogger comes to mind. That one can also easily integrate with Qt (register itself as the Qt Message handler), so your qDebug()‘s still end up in your log file.
I requested a merge request for a logger engine I wrote for it for the Windows logger stream. I don’t think it is in the 0.6 version (yet), but it should still be in the repo.
What we dot here in our custom logger is simply
std::cout<<debugString.toStdString();
in addition to writing to file.
If stdout doesn’t please you, you can use OutputDebugString
http://msdn.microsoft.com/en-us/library/aa363362(v=vs.85).aspx
to print in debug console
[EDIT: fixed link formatting, Volker]
You must log in to post a reply. Not a member yet? Register here!





