[Development] QLog ( Work on qDebug and friends)
David Faure
david.faure at kdab.com
Thu Feb 16 16:01:30 CET 2012
On Friday 10 February 2012 09:25:05 Lincoln Ramsay wrote:
> The only way to avoid some_expensive_function() is to not execute that
> code path at all. Thus the macro expansion:
>
> if (do_nothing) /*NOP*/; else qDebug() << some_expensive_function();
I think this is missing the point that qDebug() itself is a macro already
(now, in qt5).
#define qDebug QMessageLogger(__FILE__, __LINE__, Q_FUNC_INFO).debug
So why not *change* the qDebug macro to something like
if (!global_enabled()) /*NOP*/; else QMessageLogger(__FILE__, __LINE__,
Q_FUNC_INFO).debug
and the function/macro that takes categories can add the check for categories
in addition.
The goal: that global_enabled() affects *all* qDebug statements, not only those
with a category, leading to better integration, rather than to two competing
frameworks inside QtCore itself (try to explain to a new developer, the reason
why the global switch to disable debug output only works when a category is
specified...). The only reason is "well, I didn't dare to touch qDebug itself"?
I think it's the right time to touch it :-)
--
David Faure | david.faure at kdab.com | KDE/Qt Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, Sweden (HQ) +46-563-540090
KDAB - Qt Experts - Platform-independent software solutions
More information about the Development
mailing list