[Python-ideas] Efficient debug logging
Abe Dillon
abedillon at gmail.com
Thu Feb 16 16:03:28 EST 2017
>
> You are right that Python logging infrastructure can deal with logs at a
> finer grain, but the code required to do it is more verbose than logical
> switches
The default behavior of filters seems pretty useful to me (filtering by
hierarchy), but, then again, so do the default log levels. I have trouble
understanding when you would need much more, which leads me to believe
those cases are probably rare and complex (though I might very well be
wrong).
If you have a complex problem you typically should expect a complex
solution like writing a custom log filter. You might think "it would be
nice if the solution to this problem was in the standard lib", but we have
to be a little picky about what goes into the standard lib least it inflate
to a monstrous mess. If it's a niche problem, maybe a custom solution or
third party lib *is* the way to go.
and may also be non-local
There are design patterns to help with that.
and still does not solve the expensiveFunction() problem.
I wasn't trying to address that problem in that quote. I was addressing the
tangent on the insufficient expressiveness of log levels.
I personally don't see why you can't use floats for log levels, but I'm
interested to know how people are using logs such that they need dozens of
levels. That, however; is tangential to the discussion about conditional
execution of an expensive function.
On Thu, Feb 16, 2017 at 12:54 PM, Kyle Lahnakoski <klahnakoski at mozilla.com>
wrote:
>
> On 2017-02-15 16:06, Abe Dillon wrote:
>
> On 15.02.2017, 20:39 Kyle Lahnakoski wrote:
>
>> Log "levels" never made sense to me; how can a single dimension be useful
>> substitute for a number of binary switches? With log "levels", you either
>> don't have enough logging, or you drown in too much logging (or you manage
>> a number of loggers, which is worse than logging switches).
>
>
> Again, isn't that what Filters are for? I mean the documentation says:
>
>> Filters can be used by Handlers and Loggers for more sophisticated
>> filtering than is provided by levels.
>
>
>
> You are right that Python logging infrastructure can deal with logs at a
> finer grain, but the code required to do it is more verbose than logical
> switches, and may also be non-local, and still does not solve the
> expensiveFunction() problem.
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170216/f617b3fe/attachment.html>
More information about the Python-ideas
mailing list