[Bug 41199] [patch] Enhance logging system

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Mon Sep 26 13:31:40 CEST 2011


--- Comment #4 from Daniele E. Domenichelli <daniele.domenichelli at gmail.com> 2011-09-26 04:31:39 PDT ---
> 1) you can't use the QString overload of the QDebug ctor (when to send the
> string forward?)

The problem of passing the QString to the constructor of QDebug in
enabledDebug/enabledWarning is that at the end of the method the string will be
something like "tp-qt4 " PACKAGE_VERSION " DEBUG:" and I see no way to return
the string after the operator<<() has been called for all the debug or to know
when the string has been filled with the debug info.

Moreover if I create the QString inside enabledDebug it will be destroyed when
the method exits, causing sigsegv for the following operator<<()s.

So you can either:
a) Use a pointer and allocate it on the heap, but it will be likely to leak the
string because I see no way to know when it can be destroyed
b) Pass the string to the enabledDebug method, but it will break ABI
c) Use a static QString, but it might be a issue for multithreaded apps.

> 2) even if you use the QIODevice overload with some QIODevice guaranteedly
> outliving the debug object (such as a static object), you'll lose the
> boundaries between the debug messages - those being signaled by (Q)Debug
> object destruction. Note that some debug messages are legitimately
> multi-line. This might or might not be a problem to you, but I'd rather
> preserve them if anybody wants to do anything more specific than raw output
> to console or a file with them. (Think sending to an event log with
> timestamps per warning event, for example).

In my opinion this approach is safer because it simply consists in redirecting
the debug into another QDebug, handled by the main application instead of by
the library itself... The library doesn't need to care about when this QDebug
is destroyed, because it will be destroyed like every other QDebug when it goes
out of scope, that means after all the operator<<() are called.
You will still get the multiline debug in just one QDebug, exactly in the same
way that you get it using qDebug() in enabledDebug.
Until your output is generated by just one debug() call, then it will be
redirected all together in the QDebug returned by the callback method.

Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

More information about the telepathy-bugs mailing list