[Interest] Logging best practice.

Samuel Gaist samuel.gaist at edeltech.ch
Fri Dec 9 10:46:29 CET 2011


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

Hope it helps
Samuel




More information about the Interest mailing list