[Development] QLog ( Work on qDebug and friends)

wolfgang.beck at nokia.com wolfgang.beck at nokia.com
Fri Feb 17 02:23:21 CET 2012


Dammit,
copied the wrong stuff.

I mean I'm using:

#define qLog(category)                        \
	    if (!QLog::instance()->isEnabled() || !QLog::instance()->isEnabled(#category, QLogCategories::category##_QLog_enabled)) /*NOP*/; \
			    else QMessageLogger(__FILE__, __LINE__, Q_FUNC_INFO, #category).debug()         


Cheers,
 WB

________________________________________
From: Beck Wolfgang (Nokia-MP/Brisbane)
Sent: Friday, 17 February 2012 9:39 AM
To: ext David Faure; development at qt-project.org
Subject: RE: [Development] QLog ( Work on qDebug and friends)

Already done.

I'm using
if (!global_enabled()) /*NOP*/; else QMessageLogger(__FILE__, __LINE__, Q_FUNC_INFO).debug

Anyway I will make sure that qlog still works even with -DQT_NO_WARNING_OUTPUT

Cheers,
 WB

-----Original Message-----
From: development-bounces+wolfgang.beck=nokia.com at qt-project.org [mailto:development-bounces+wolfgang.beck=nokia.com at qt-project.org] On Behalf Of ext David Faure
Sent: Friday, February 17, 2012 1:02 AM
To: development at qt-project.org
Subject: Re: [Development] QLog ( Work on qDebug and friends)

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

_______________________________________________
Development mailing list
Development at qt-project.org
http://lists.qt-project.org/mailman/listinfo/development



More information about the Development mailing list