[Bug 41199] [patch] Enhance logging system

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Mon Sep 26 11:46:16 CEST 2011


https://bugs.freedesktop.org/show_bug.cgi?id=41199

--- Comment #2 from George Kiagiadakis <kiagiadakis.george at gmail.com> 2011-09-26 02:46:14 PDT ---
(In reply to comment #1)
> 09:45 < oggis_> so also, this tpDebugCallback proposed would actually lose the
> KDebug part of the constructed debug object and it'd turn into a bare QDebug
> instead (however much that matters)

fyi, KDebug is not a subclass of QDebug. It's another object that is used as a
C++ syntax trick to pass the __FILE__ and __LINE__ constants to kDebugStream().
In the end, it returns a QDebug object constructed with the QDebug(QIODevice*)
constructor, which then redirects everything to the QIODevice.

So, redirecting to a file with Daniele's approach would be something like:

static QIODevice *s_file; //or better, Q/K_GLOBAL_STATIC

QDebug tpDebugCallback(QtMsgType type) {
    //possibly redirect to a different file or /dev/null depending on the type
    return QDebug(s_file);
}

int main() {
   ...
   s_file = new QFile("/foo/bar");
   Tp::setDebugCallback(tpDebugCallback);
   ...
}

And it is not limited at all, since you can create a QIODevice subclass and do
anything (see kdebug.cpp for examples).

That said, I am not particularly in favor of one approach over the other. I
think both approaches are similar in terms of possibilities and ease of use.

-- 
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