[Interest] Logging best practice.

kai.koehne at nokia.com kai.koehne at nokia.com
Fri Dec 9 10:31:26 CET 2011


Hi,

> -----Original Message-----
> From: interest-bounces+kai.koehne=nokia.com at qt-project.org
> [mailto:interest-bounces+kai.koehne=nokia.com at qt-project.org] On Behalf
> Of ext alex.blasche at nokia.com
> Sent: Thursday, December 01, 2011 7:28 PM
> To: stefano.cordibella at edalab.it; interest at qt-project.org
> Subject: Re: [Interest] Logging best practice.
> 
> 
> 
> > -----Original Message-----
> > From: interest-bounces+alex.blasche=nokia.com at qt-project.org
> > [mailto:interest-bounces+alex.blasche=nokia.com at qt-project.org] On
> 
> >     is the state of the art use the debug functions (qDebug, qWarning,
> > ...) in conjunction with a custom message handler (qInstallMsgHandler)
> > for log to file system?
> > I found very simple and useful this approach, but I think that a log
> > function with message level is needed (i.e: qMessage() ) for a
> > complete set of logging levels.
> > Anyone else think that we need a new function with message log level?
> 
> I do. We are actually working on something based on qLog
> (http://docs.huihoo.com/qt/qtextended/4.4/debug-qtextended.html#qlog-
> categorized-logging)
> 
> Initially we only started to look at it because we needed something in
> QtSensors but I definitely see this as a more generic thing. Besides porting it
> to Qt5 we are still investigating its usefulness as a generic Qt5 thing. We
> should soon have some preliminary results.

I for one would really like to have an improved logging framework in Qt5 :)

Since it's Christmas soon, I'd like to add one thing to the wishlist : A way to add a file/line info to the log. This way you'd be able to see where in the source code a specific message was raised . 

Syntax could e.g. be:

qLog(QWidget).location(__FILE__, __LINE__) << "Created" << name;

(Maybe __FILE__ , __LINE__ can be automatically retrieved by yet another macro? Not sure ...).  

For logs coming from .js (console.log(), console.debug() ...) the source location would automatically be set. 

Just  my 2 cents,

Kai

> So I guess, watch this space...
> 
> --
> Alex
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest



More information about the Interest mailing list