[Bug 41199] [patch] Enhance logging system

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Tue Sep 27 00:18:00 CEST 2011


--- Comment #6 from Daniele E. Domenichelli <daniele.domenichelli at gmail.com> 2011-09-26 15:17:59 PDT ---
I see at least 2 problems that add a lot of complexity in comparison to the
first approach:

1) enableDebug returns a Tp::Debug by value, and this means that (depending on
   the compiler?) a copy of the object is created and then destroyed the first
   one destroyed when it goes out of scope. Therefore having a hook in the
   destructor of Tp::Debug means that the callback will be called at least
   twice (once per copy of the Tp::Debug)

2) Tp::Debug will have to store internally the QString. This QDebug(QString*)
   ctor doesn't allow to set a QtMsgType so it will have to be stored in
   Tp::Debug as well. The QDebug(QString*) constructor requires that the string
   is constructed before the QDebug in Tp::Debug ctors. Copy constructor and
   operator= cannot simply copy the QDebug* but must copy these as well. 
   Moreover they cannot copy the QDebug because the stream of the second will
   point at the QString in the first whose life might be shorter. It should
   create a new QDebug to its own QString and feed it with the other

Anyway I tried to do it, but to keep the things as simple as possible, I
stored everything in a refcounted struct and kept a Tp::SharedPtr in Tp::Debug
The callback function is called by the struct dtor instead of by Tp::Debug
Anyway I'm not sure if I can use the Tp::SharedPtr here... is there any reason
why I shouldn't?


(if you change your mind and decide that you like the QDebug approach more I
updated the logging_enhancement branch fixing the name of the function pointer

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