[Development] Work on qDebug and friends - debug areas

Olivier Goffart olivier at woboq.com
Wed Jan 25 18:28:18 CET 2012


On Wednesday 25 January 2012 13:18:33 Thiago Macieira wrote:
> On Wednesday, 25 de January de 2012 14.28.04, kai.koehne at nokia.com wrote:
> > I guess the KDebug::registerArea David mentioned does pretty much that.
> > I
> > researched a bit whether you somehow can do hashing already on compile
> > time, but it seems not to be possible even with Cx11  If you're doing
> > something like qHash you most probably don't want to do it in  every
> > single qDebug line ...
> 
> Olivier managed to hash at compile-time with C++11 using constexpr.

But that was not what I meant.
I mean we can choose number with qHash or even qrand(), and then hardcode that 
number in the source code. 

class QPluginManagerPrivate { enum { DebugArea = 1546743 }; ... }; 
// number randomly chosen

qDebug(DebugArea) << "try to load" << plugin; //in QPluginManagerPrivate::load

QT_ENABLE_DEBUG=1546743 ./myapp
And because this is just a debug tool, looking up number in the code is good 
enough
(but if the number is, by convention, choosen with qHash, we could also do 
QT_ENABLE_DEBUG=plugins)


KDebug::registerArea needs a registery. That works for KDE, but I don't know 
if that is a good idea for Qt

But I just wanted to give one idea (which I think is good :-D).
If you want to implement a more complex solution, go for it :-)




More information about the Development mailing list