[Development] Categorized logging inside Qt

Rutledge Shawn Shawn.Rutledge at digia.com
Fri Apr 11 08:41:18 CEST 2014


On 10 Apr 2014, at 7:20 PM, Frederik Gladhorn wrote:

> Hi all,
> 
> I just started to port accessibility to the new and shiny categorized logging.
> http://blog.qt.digia.com/blog/2014/03/11/qt-weekly-1-categorized-logging/
> 
> I'd propose we decide on a certain style of declaring categories.
> 
> A quick grep shows that we already have some variety, I'd like to unify this 
> before Qt 5.3 is out of the door. I actually saw a patch adding DBG_FOOBAR as 
> new category, that made me wonder about which style we should use.

I think the pattern is OK though: all uppercase, with a prefix like DBG and try to keep them as short as possible since they get repeated all over.

I guess we shouldn't ever put Q_DECLARE_LOGGING_CATEGORY declarations in public headers, right?  Or would it be an advantage to expose a few so that applications can send messages to a few common, documented categories?  If not, then the pattern should probably be to put them in private headers so that they can be used across multiple modules.  E.g. in qtdeclarative I have a patch to add qt.quick.touch, qt.quick.mouse, qt.quick.focus etc. to qtquickglobal_p.h because I expect that tracing handling of touch events etc. will eventually be pervasive in quite a few classes, although for now it's only used in QQuickWindow.  Historically I keep writing patches to add log messages over and over again, and never commit them.  It will save some work later to have these nicely organized into categories that can be enabled any time, even when a user reports some bug in the field.  I'm also worried about the runtime and memory cost of having them always thereā€¦ but we were told not to worry.  ;-)  I hope it's true.




More information about the Development mailing list