Qt6 topics merged with General

QDebug passing custom debug message type

  • We are building a static library that is using qDebug and custom qDebug message handler. Because of this every qDebug and its variants are redirected to our message handler. But we don't want to handle application's qDebug in our message handler. One work around we can do is that passing custom qDebug message type in the QDebug that we are using inside our static library and checking for this in qMessageHandler callback. But is this safe? Another way we thought of is creating a class that is similar to QDebug and overload << operator for every data type same like QDebug does. Can any one please tell whether there is any easier way to achieve this? Thanks in advance.

  • Moderators

    Use categorized logging. https://doc.qt.io/qt-5/qloggingcategory.html That should help in separating the logs from different modules/ libs.

  • This post is deleted!

  • @sierdzio Thank you. We also thought of using that at first. But because of some reason we have to use qt 4.7. And categorised logging is available in qt 5.2+ .

Log in to reply