[Qt-interest] install message handler
Andre Somers
andre at familiesomers.nl
Thu Sep 2 11:56:24 CEST 2010
Op 2-9-2010 11:28, Sajjad schreef:
> Hello forum,
>
>
> I am trying all my debug output to a file and i tried using the
> qInstallMsgHandler.the function pointer contains the following definition:
>
> ************************************************
>
> #include "Util.h"
>
> #include <iostream>
>
> void debugMessageHandler(QtMsgType type, const char *msg)
> {
> static QFile *file = new QFile(":/H3D/debugOut.txt");
>
> if(!file->exists())
> std::cout << "file does not exist" << std::endl;
> else
> std::cout << "File is there" << std::endl;
>
> QTextStream out(file);
> switch(type)
> {
> case QtDebugMsg:
> out << "Debug" << QString(msg);
> break;
> }
> }
>
> ********************************************************************
>
>
> I install the handler in the main function and it is supposed to be
> functional from anywhere in the project, right?
>
>
> After every debug output with qDebug() i chcek the contents of the
> file and it is still empty.
>
>
> Is there anything i am missing in the process?
>
>
>
> Regards
> Sajjad
>
In addition to the above messages, perhaps you are interested in
QxtLogger. It supports multiple logger engines, including logging to a
plain text or to an xml file. You can set it to be the sink for qt's
debug and warning outputs too.
André
More information about the Qt-interest-old
mailing list