[Solved] How to show Qt debug messages outside the debugger



  • The Qt framework shows a lot of useful debug messages (signals not properly connected as a very prominent example) at runtime but more generally this applies to all debug messages build into an application.
    Unfortunately (at least unter OSX and Windows) the messages are only visible when running the application in a debugger.
    Is there a strait-forward way to see those message outside a debugger?



  • when you say out side of debugger, Do you mean on Terminal/console? If yes then you do get those message on console. I do not remember 100% but there is some macro which gives you the warnings. May be other members give some more info, Or you may like to ask this on qt-interest mailing list as I personely think there you have much more members since years to help.



  • Add this to your qmake .pro file
    @
    CONFIG += console
    @



  • What actually want to do.
    Do you want to transfer those msgs outside that console debugger ?

    Suppose ,I am using Qt creator, then the msgs which are created only in the debug environment, I have not seen it.

    Because user does not have the access to the debug handling property.

    regards,



  • Make changes to your .pro file as bradley has mentioned.

    Also you can explore more options

    @CONFIG += qt warn_on release rtti exceptions @



  • [quote author="Bradley" date="1293091435"]Add this to your qmake .pro file
    @
    CONFIG += console
    @
    [/quote]

    I've just tried to add this CONFIG option to a sample project but cannot see any changes under OSX. I've added a simple
    @
    qDebug() << "test";
    @
    that is shown in the debugger and QtCreator but cannot be seen when running my sample using open from by shell.

    Could you please give me some more information on:

    • What this configuration is supposed to do and/or where to find the documentation?
    • To what this option in qmake translates in a simple makefile?

    Thank you!



  • [quote author="qtrahul" date="1293091619"]What actually want to do.
    Do you want to transfer those msgs outside that console debugger ?

    Suppose ,I am using Qt creator, then the msgs which are created only in the debug environment, I have not seen it.

    Because user does not have the access to the debug handling property.

    regards,[/quote]

    What I'm actually investigating is how to make this (debug output) information available to others then the actual developer. In my case this would typically be someone from Q&A doing alpha and beta tests or end users doing beta testing using debug builds.

    The debug messages are often extremely useful to track down problems while testing and it would somehow be nice to have a little window aside of the actual application that shows the debug messages as they show up. This can for sure be implemented individually using a customized logging but I was just wondering what the "standard" functionality of the Qt Framework offers.



  • Seems in that case you will have to log it to a file.



  • You can install message handlers in Qt, to catch the debug messages and do with them, what you need. I know, there is a possibility, but I'm not 100% sure, how.



  • I looked a bit for information about this topic:
    "Here som general things about debugging (also to Mac)":http://doc.qt.nokia.com/4.7/debug.html

    bq. The Qt implementation of these functions prints the text to the stderr output under Unix/X11 and Mac OS X. With Windows, if it is a console application, the text is sent to console; otherwise, it is sent to the debugger. You can take over these functions by installing a message handler using qInstallMsgHandler().

    So it also shows a way you can go to use "custom message handlers":http://doc.qt.nokia.com/4.7/qtglobal.html#qInstallMsgHandler



  • On Mac OS X the debug output goes to the system logger. You can read it with the Console Application (Usually in /Applications/Utilities/Console.app).

    For your own logging facilities "qInstallMsgHandler()":http://doc.qt.nokia.com/latest/qtglobal.html#qInstallMsgHandler is your friend (that's the solution Gerolf mentioned).

    I once wrote a small GUI that collects the qXXX() messages. I can put it in the wiki on request.



  • You can get some help using qInstallMsgHandler() from "this":http://lists.trolltech.com/qt-interest/2006-05/msg00602.html thread too.



  • QxtLogger can install itself the hander for Qt's debug messages as well, and you can use several outputs for your logging info. StdErr/StdOut of course, but also files in different formats.

    The qt += console suggestion given earlier only works on windows.



  • [quote author="Volker" date="1293097794"]On Mac OS X the debug output goes to the system logger. You can read it with the Console Application (Usually in /Applications/Utilities/Console.app).

    For your own logging facilities "qInstallMsgHandler()":http://doc.qt.nokia.com/latest/qtglobal.html#qInstallMsgHandler is your friend (that's the solution Gerolf mentioned).

    I once wrote a small GUI that collects the qXXX() messages. I can put it in the wiki on request.[/quote]

    I think it would be great if you could make your "small GUI that collects the qXXX() messages" available to everyone.



  • @Volker, that would be really nice of you.



  • [quote author="Volker" date="1293097794"]On Mac OS X the debug output goes to the system logger. You can read it with the Console Application (Usually in /Applications/Utilities/Console.app).

    For your own logging facilities "qInstallMsgHandler()":http://doc.qt.nokia.com/latest/qtglobal.html#qInstallMsgHandler is your friend (that's the solution Gerolf mentioned).

    I once wrote a small GUI that collects the qXXX() messages. I can put it in the wiki on request.[/quote]

    Yes, everyone would like such a handy tool.



  • Request :-))



  • I've added a "wiki page":http://developer.qt.nokia.com/wiki/Browser_for_QDebug_output with the source code of the QDebug Log Output Browser.

    I hope it is useful for somebody and of course feel free to ask, if you have questions.



  • Thanks Volker, I was also looking for something similar :)



  • [quote author="Volker" date="1294011522"]I've added a "wiki page":http://developer.qt.nokia.com/wiki/Browser_for_QDebug_output with the source code of the QDebug Log Output Browser.[/quote]

    Thanks Volker, fiddling with it at the moment... :-)



  • I added the .pro file, that was missing from the first version.



  • [quote author="Volker" date="1294011522"]I've added a "wiki page":http://developer.qt.nokia.com/wiki/Browser_for_QDebug_output with the source code of the QDebug Log Output Browser.
    I hope it is useful for somebody and of course feel free to ask, if you have questions.[/quote]
    Thank you!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.