[Development] QLog ( Work on qDebug and friends)
lincoln.ramsay at nokia.com
Mon Feb 20 03:21:43 CET 2012
On 02/17/2012 06:23 PM, ext David Faure wrote:
>> There is no "global switch" to "disable debug output" with qLog.
> What's QLog::instance()->isEnabled() then ?
An optimization from back when you had to call a C++ method to enable
logging and when each category check involved QMap and QString
operations. I have my doubts that this even needs to exist anymore. It
may even hurt performance in a corner case to have this function.
>> Please read the code before commenting on the implementation.
> Hey, I reviewed on that change before I even wrote here. But the global switch
> idea comes from your own email from 10/02, which says:
> if (!global_enabled() || !category_enabled(cat)) /*NOP*/; else qDebug()"
> I didn't make up that notion of global_enabled(), it's from you...
Ok, but see above. There is no "switch" that controls that anymore.
> Sorry I didn't mean "the qDebug macro/API", but the QDebug implementation.
> I'd like qDebug() and qLog() to share as much as possible of the
So do we :)
There's more merging going on that may not be visible in the change yet.
qLog() and qDebug() will both use QMessageLogger and (unless you've used
qLog to write to a file) the default message handler will be invoked so
the formatting will match.
> QT_MESSAGE_PATTERN should affect both,
> qInstallMessageHandler should affect both, etc.
I wrote the above before I saw this.
> More generally, sharing the
> same output subsystem (with the addition of logging to files, but that's
> downstream from the shared formatting and handler-hook code).
Yes, with one caveat.
We feel the use case of "I have no add-on but I want logs captured to a
file" merits the inclusion of file-writing code into QtCore. This is
turned on via the qlog config file and the formatting for this can be
set in the config file.
But you can most certainly ignore that and do output from a message
handler (or use an add-on that gives you output options, once it exists).
Lincoln Ramsay - Senior Software Engineer
Qt Development Frameworks, Nokia - http://qt.nokia.com/
More information about the Development