[Development] QLogger questions and proposal
mzraly at gmail.com
Mon Apr 30 16:37:17 CEST 2012
On Mon, Apr 30, 2012 at 1:27 AM, Lincoln Ramsay <lincoln.ramsay at nokia.com>wrote:
> On 04/25/2012 12:44 AM, ext Mike Zraly wrote:
>> On Mon, Apr 23, 2012 at 7:57 PM, Lincoln Ramsay
>> <lincoln.ramsay at nokia.com <mailto:lincoln.ramsay at nokia.**com<lincoln.ramsay at nokia.com>>>
>> I'm a little concerned about performance during shutdown if there are a
>> large number (say 100 or more) of QLoggingCategory objects listed in
>> _registeredCategories though, as each each call to QList::removeOne will
>> do a linear scan for the address to remove. In the worst case where
>> QLoggingCategory objects are destructed in reverse order of their being
>> added to _registeredCategories the time for scanning will grow as
>> O(n**2). That can be addressed later if it turns out to be a real
>> problem in practice.
> With the current setup, this won't be a problem because QLoggingPrivate
> will be destructed before any of the category objects are.
I see, because QLoggingPrivate is function-static, not file-static, and
this is safe because of the privateUnloaded flag in your patch. Cool.
> > 2. Get rid of the QT_LOG_CATEGORY macro and expose QLogging category
>> > directly.
>> Yeah... what I said before.
>> I think there is merit in this idea. We may have to be a little careful
>> since people have already started using this code (ie. I'd like to keep
>> source compatibility) but I think this is worth a try.
>> Fair enough. But if you must keep QT_LOG_CATEGORY redefine it so that
>> you can still pass QLoggingCategory references or addresses to qCDebug.
>> The key to that is using QT_LOG_CATEGORY's first argument as the
>> generated variable name, then exposing whatever namespace it is in to
>> the code that calls qCDebug. I see three options:
>> 1. Skip the namespace altogether, rely on the static keyword to limit
>> the variable's scope.
>> 2. Use an unnamed namespace for the same effect.
>> 3. Add using directives to expose the QtLogger::QLoggingCategories
>> Options 1 or 2 seem the simplest to me, but there may be reasons for
>> using the namespace that I have overlooked.
> I put some of this into a bug report. If you would like to comment further
> on it, feel free to do so.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Development