> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On
> Behalf Of ext BRM
> Sent: Tuesday, February 14, 2012 3:00 PM
> To: [email protected]
> Subject: Re: [Development] QLog ( Work on qDebug and friends)
>
> ----- Original Message -----
>
> > From: "[email protected]" <[email protected]>
> >> -----Original Message-----
> >> From: [email protected]
> >> [mailto:[email protected]]
> On
> >> Behalf Of Ramsay Lincoln (Nokia-MP/Brisbane)
> >> Sent: Monday, February 13, 2012 1:33 AM
> >> To: [email protected]
> >> Subject: Re: [Development] QLog ( Work on qDebug and friends)
> >>
> >> On 02/11/2012 01:44 AM, ext [email protected] wrote:
> >> > However, adding yet another 'keyword' to the framework has a
> > price,
> >> > especially since the difference between >
> >> 'qDebug(QMessageLogContext("MyCategory"))'<<
> > and a
> >> > 'qLog("MyCategory")<< ' is subtle.
> >>
> >> We tried that but while this difference is subtle to the eye, it's a
> >> huge difference to the implementation.
> >>
> >> qDebug is currently an argument-less macro that expands to the name
> >> of a function. Before message logging it was just a plain old function.
> >> Overloading means that qDebug("message") and qDebug() <<
> > "message"
> >> both
> >> work.
> >>
> >> Since we can't have a macro func with 0, 1 or many arguments, we can
> >> only add a new overload for qDebug(category) << "message"
> > but if we do
> >> this, there is nowhere to put the "do nothing quickly" logic.
> >
> >
> > Just wanted to point out that there are variadic macros:
> > http://gcc.gnu.org/onlinedocs/cpp/Variadic-Macros.html
> >
> > #define qCategoryDebug(category, ...) if (isLogEnabled(category))
> > QMessageLogger(__FILE__, __LINE__,
> Q_FUNC_INFO).debug(__VA_ARGS__)
> >
> > Seems to work with at least gcc4.2.1 and Visual studio 2010.
> >
> > But that doesn't help with the fact that we can't differentiate
> > between 'qDebug()', 'qDebug("Hello world")', and 'qDebug(MyCategory)'
> > on the macro level.
>
>
> That depends on implementation. It does allow you take all those args and
> pass them over to other function easily.
> And if all categories have to be registered, then you can add a check against
> the registration for it:
>
> ..
> qLogRegisterCategory("my category");
> ...
> qDebug("my category",...");
> ...
> qDebug(...);
> ...
>
> #define qDebug(category,...) \
> if (qLogIsCategory(category)) \
> if (qIsLogEnabled(category)) \
> QMessageLogger(__FILE,__LINE__, Q_FUNC_INFO,
> category).debug(__VAR__ARGS__) \
> else {} \
> else QMessageLogger(__FILE,__LINE__,
> Q_FUNC_INFO).debug(category,##__VAR__ARGS__)
Nice, though it'll break with
qDebug() << "Hi there";
"too few arguments to function bool qLogIsCategory(const char*)"
Also this won't work:
qDebug("category") << "HI there";
"expected primary expression before the '<<' token.
:(
Regards
Kai
_______________________________________________
Development mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/development