Quantcast
Channel: Jobs
Viewing all articles
Browse latest Browse all 18427

Enhanced QDebug class set

$
0
0
Hi all, Have you all also been annoyed by the fact that QDebug does not allow for fine grained module based logging ? And that you cannot set it on or on the fly ? Well I created a template based 2-file enhancement on top of regular QDebug (hence supporting all features of QDebug) allowing for all of the above. Here briefly what you can do first you need to include the new debug header file #include <apdebug.h> You need to declare each ‘module’ you wish to control to the system. This can be done in one of two // if you have a class that ‘controls’ the module (the controlling class must be accessible to each other class // that wants to log using the same debug module (class header must be included static Debugging<ClassThatIsSpecificToThisModule> Debugging( “StringNameIdentifyingThisClass” ); // or if you do not have a class int DebugFlag = false; static StaticDebugging StaticDebugging( “SomeName for the non-class related module”, &DebugFlag ); // next you can use a new version of qDebug (APDebug) like APDebug<ClassThatIsSpecificToThisModule>() << … // regulare qDebug arguments // or for non class related modules StaticDebug( DebugFlag ) << … to list the debug state of all known modules foreach( const QString & Mod, DebuggingAbstract::moduleList() ) { qDebug() << “Module” << Mod << “debug” << DebuggingAbstract::debugIsEnabled(Mod); } controlling the state of debugging is done using // enable disable all known modules DebuggingAbstract::enableDebug( true ); // enable disable specific module DebuggingAbstract::enableDebug( “ModuleName”, false ); // or true to enable I would like to provide this code snippet to the community and offer it for scrutiny and enhancements. Just tell me where … Greetz

Viewing all articles
Browse latest Browse all 18427

Trending Articles