[Development] Work on qDebug and friends

Diego Iastrubni diegoiast at gmail.com
Tue Jan 24 13:18:28 CET 2012


On Tue, Jan 24, 2012 at 12:41 PM, <kai.koehne at nokia.com> wrote:

> I've been working on a patch to the Qt logging framework:
> http://codereview.qt-project.org/#change,13433,patchset=14 . Basically it
> redefines qDebug() and friends as a macro so that we can automatically
> capture the source file, line, and function a particular message comes from:
>
>  qDebug("Hello world")
>
> actually is changed by the precompiler to:
>
>  QMessageLogger(__FILE__, __LINE__, Q_FUNC_INFO):debug("Hello World")
>
> The additional information can then be processed in a custom message
> handler, that also got a new signature:
>
> void myMessageHandler(QtMsgType type, const QMessageLogContext &context,
> const char *msg)
> {
>  switch (type) {
>    case QtDebugMsg:
>        printf("DBG: %s (%s:%i in %s)\n", msg, context.file, context.line,
> context.function);  }
>        break;
>   // ...
> }
>
>

So, if I want to have also time/date on my logs, should I install a new
message handler?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20120124/4da68252/attachment.html>


More information about the Development mailing list