I'm developing a Qt application. For each class, I'm trying to mimic the framework, such as error() and errorString() method, use of Private implementation.
But I would like to add a per class debugging:
- Set a macro to the desired level of debug,
- have a macro or a function that knows the level of debug, and use qDebug() or qWarning() which is class independa开发者_Python百科nt, and will know the current class's name (for some pretty prints)
Anyone have a good idea to implement this ?
Maybe the QxtLogger class, part of the Qxt library (an extension library for Qt) provides what you need.
I would definitely consider using something already existing and tested rather than implementing my own logging solution.
You may write a class, for example CDebug with all needed debug methods, and use it in other classes, like:
class CMyDialog : public QDialog, public CDebug {...};
精彩评论