Most of the time, it's just a question of sending the desired message (a QtMsgType value) to the output stream provided by qDebug():
qDebug() << "Date: " << QDate::currentDate();Moreover, the streaming operator << can be extended to provide support for custom types, for instance:
QDebug operator<<(QDebug dbg, const Circle &c) { dbg.nospace() << "Radius: " << c.radius(); return dbg.space(); }
Make it persistent
What if we need to get a copy of all the debug messages thrown by the application during a debugging session?