Reputation: 27
I have follwing code snippet to run. In which I want to see result of qDebug() but I dont want see result of qInfo(). I want to configure it on basis, sowetimes I need those qInfo() output and sometimes not.
qInfo()<<"Info print";
qDebug()<<"Debug print";
In above code, I want only 'Debug print' should print. but can't comment qInfo() line.
Upvotes: 0
Views: 1333
Reputation: 2354
You can choose at runtime which category enable (even for custom category) with QLoggingCategory::setFilterRules
From Qt Docs, exampe with custom category:
QLoggingCategory::setFilterRules(QStringLiteral("driver.usb.debug=true"));
For your case:
QLoggingCategory::setFilterRules(QStringLiteral("*.info=false"));
take care of using "*.info=true"
because enable everything, even for profiling category usually disablet
Upvotes: 1
Reputation: 4049
As it described on the Qt debug documentation, you have to compile with QT_NO_INFO_OUTPUT
to disable it.
# your .pro file
DEFINES += QT_DEPRECATED_WARNINGS QT_NO_INFO_OUTPUT
You can also use define for other macro:
qDebug()
: disable withQT_NO_DEBUG_OUTPUT
qInfo()
: disable withQT_NO_INFO_OUTPUT
qWarning()
: disable withQT_NO_WARNING_OUTPUT
qCritical()
: enable withQT_FATAL_CRITICALS
Upvotes: 2