[Interest] Logging best practice.

kai.koehne at nokia.com kai.koehne at nokia.com
Fri Dec 9 11:06:22 CET 2011


> -----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 Samuel Gaist
> Sent: Friday, December 09, 2011 10:46 AM
> To: interest at qt-project.org
> Subject: Re: [Interest] Logging best practice.
> 
> 
> On 9 déc. 2011, at 10:31, <kai.koehne at nokia.com>
> <kai.koehne at nokia.com> wrote:
> 
> > 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
> 
> Hi,
> do you think about about something like Q_FUNC_INFO ?
> 
> http://doc.qt.nokia.com/4.7/qtglobal.html#Q_FUNC_INFO

Hi,

Well, I regularly do

  qDebug() << Q_FUNC_INFO;

when debugging my own stuff :) Anyhow, this makes the information a part of the message itself, with no easy way to hide/unhide it afterwards. It also misses file/line information ...

Okay, here's the background for my request: We're working on getting a fully-fledged JavaScript/QML console window into Qt Creator (debugger). Right now QML compilation errors, console.log etc all end up in qDebug() or qWarning(), and therefore as plain text into stdout/stderr or it's Windows equivalent. But wouldn't it be cool to have a console like http://gemal.dk/mozilla/pics/mozdev02.png for QML and Cpp log messages?

 * Jump directly to the source file / line where a log message is emitted, by just clicking on it
 * Filter messages according to their level in the console

Regards

Kai

> Hope it helps
> Samuel
> 
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest



More information about the Interest mailing list