[Development] Work on qDebug and friends

Diego Iastrubni diegoiast at gmail.com
Tue Jan 24 14:27:02 CET 2012


On Tue, Jan 24, 2012 at 2:39 PM, <kai.koehne at nokia.com> wrote:
>
> Well, I plan to work on a simple environment switch which will enable the default logger to show the file, line, and the log level. My idea is that an IDE e.g. Qt Creator sets this environment variable, and voila, you can suddenly click on your log messages :)
>
> Anyhow, there's a lot of things people might want to log in addition ( date, time, PID, QThread id ...). Some might also want to log to a file, or a database. Finally, the exact configuration might be compiled in, decided at load time (e.g. via an environment variable), or even at run time (e.g. http://codereview.qt-project.org/#change,13226 proposes to watch a file for possible configuration changes) ...
>
> So, instead of trying to add all of this over time to QtCore, I think we should rather go for a separate Qt Logging Addon that contains all of this. What we've to ensure right now is that the key enablers are there in Qt Core (see also the debug areas thread). Time and date can be trivially computed in any handler later on.
>

At my work place me use a system that lets you agregate loggers. We
have one for console, file, DB, Win32 registry and I once wrote a
remote logger which sits on top of that. The API was similar to this:

MainLog::instance()->addLogger( new FileLogger) );
MainLog::instance()->addLogger( new ConsoleLogger) );
MainLog::instance()->log( __FILE__, __LINE__, __FUNCTION__, logLevel, "Hello!");
etc.

I added also macros to log function entries and function exit (to get
a lame dtrace implementation).

I would lite Qt to have something similar, but I assume that is
another layer which can be added as a 3rd party addon.



More information about the Development mailing list