[Python-ideas] Efficient debug logging
Barry
barry at barrys-emacs.org
Tue Feb 14 16:55:27 EST 2017
> On 14 Feb 2017, at 17:03, Cory Benfield <cory at lukasa.co.uk> wrote:
>
>
>> On 14 Feb 2017, at 15:51, Barry Scott <barry at barrys-emacs.org> wrote:
>> And have the evaluation of the argument skipped unless its dbg_log is enabled.
>>
>> I cannot see how to do this with python as it stands.
>>
>> Something would have to be added to allow python to short circuit the argument tuple evaluation.
>>
>> Maybe python can check for a special dunder on the class that know how to do this idiom, __if_true_call__?
>>
>
> Is there any reason logger.isEnabledFor(level), as shown in the docs https://docs.python.org/2/library/logging.html#logging.Logger.isEnabledFor, is not sufficient for this?
The point is that the cost of creating the msg argument can be very high.
At the point that logging decides to skip output it is to late to save the cost of creating the arg tuple.
Not that it is relivent for this idea bit logging's levels are too course for logging in complex applications. The app I am working on at the moment has 20 seperate debug categories
that are independently enabled.
Barry
> Cory
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170214/3079a3c2/attachment.html>
More information about the Python-ideas
mailing list