Enhanced QDebug class set
-
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
Edit: I put your code sections between @ tags for you; Andre
-
Hi, thanks for this. Please wrap your code in '@' tags.
You can push your code to github like everybody does :)
-
Hmm sorry but I am an subversion users and not git ... any howto I could read on that.
about that @ tags ... how does that work ?
-
Put your code between two '@' signs, like this:
@
// This is a code inside a comment block
void main() {}
@Well, it's your choice. You loose a lot in life by not using git. But there are plenty of public SVN servers, too: sourceforge, Google code, etc.