[Development] Work on qDebug and friends

kai.koehne at nokia.com kai.koehne at nokia.com
Fri Feb 3 11:51:50 CET 2012


> -----Original Message-----
> From: development-bounces+kai.koehne=nokia.com at qt-project.org
> [mailto:development-bounces+kai.koehne=nokia.com at qt-project.org] On
> Behalf Of Koehne Kai (Nokia-MP/Berlin)
> Sent: Tuesday, January 24, 2012 1:39 PM
> To: diegoiast at gmail.com
> Cc: development at qt-project.org
> Subject: Re: [Development] Work on qDebug and friends
> 
> > -----Original Message-----
> > From: ext Diego Iastrubni [mailto:diegoiast at gmail.com]
> > Sent: Tuesday, January 24, 2012 1:18 PM
> > To: Koehne Kai (Nokia-MP/Berlin)
> > Cc: development at qt-project.org
> > Subject: Re: [Development] Work on qDebug and friends
> >
> > So, if I want to have also time/date on my logs, should I install a
> > new message handler?
> 
> Well, I plan to work on a simple environment switch which will enable the
> default logger to show the file, line, and the log level. My idea is that an IDE
> e.g. Qt Creator sets this environment variable, and voila, you can suddenly
> click on your log messages :)

Finally I came around to actually implement something:

http://codereview.qt-project.org/#change,15129

The idea is that you can customize the output by setting the QT_DEBUG_PATTERN environment variable. Setting it e.g. to

"[%type%] %file%:%line% %function% %message%" 

Would generate lines like:

[debug] ../helloworld/main.cpp:7 main HELLO WORLD

However, I'm not really sure whether that belongs into Qt Core or not. I'm happy to move the code elsewhere if we're going for a separate plugin/module. That's why it's also not a completely polished patch (documentation is missing + there is an ugly busy wait for concurrent access in qMessageHandlerTokens. Any hints for more elegant solutions are welcome).

Regards

Kai Koehne

PS: The code simplifying Q_FUNC_INFO output (qCleanupFuncinfo) stems from Thiago . The autotest that he also wrote is producing some failures though :(



More information about the Development mailing list