Simple qdebug question
i need to change the normal qdebug()<<"test" into a function which indicates the debug level and compiles if only debugmode is set,
Something like the following
I should call the function the same way as normal but with debug level between brackets in order to simplify editing ..
I don't know if it is possible to do .. how would the function header look like? .. help is appreciated, thanks
Have a look at qCDebug() instead of qDebug() :) http://qt-project.org/doc/qt-5/qloggingcategory.html#qCDebug
this does not help .. QCDebug is a logging mechanism and not what i need .. how should i use it to represent loglevel?
qDebug() is a logging mechanism too. qCDebug() is just a more powerful version of qDebug().
You asked for a way to set debug levels with less code than your first post. Well, logging-categories let you do that.
#define D1ENABLED true
// This line only needs to be called once.
// You can then use qCDebug(DBG_LVL1) in your whole app.
qCDebug(DBG_LVL1) << "test"; return 0;
You will get an output if D1ENABLED is true. Otherwise, you won't get an output.
thank you, it seems much easier now.. I will give it a try
but how about not being compiled if no debug is requested ???