<div dir="ltr"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span style="font-size:12.8px">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</span></blockquote><div><br>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).<br><br>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.<br><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span style="font-size:12.8px">and may also be non-local</span></blockquote><div><br>There are design patterns to help with that.<br><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> <span style="font-size:12.8px"> </span><span style="font-size:12.8px">and still does not solve the expensiveFunction() problem.</span></blockquote><div><br>I wasn't trying to address that problem in that quote. I was addressing the tangent on the insufficient expressiveness of log levels.<br><br>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.</div></div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 16, 2017 at 12:54 PM, Kyle Lahnakoski <span dir="ltr"><<a href="mailto:klahnakoski@mozilla.com" target="_blank">klahnakoski@mozilla.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000"><span class="">
<br>
<div class="m_-7941316021455768539moz-cite-prefix">On 2017-02-15 16:06, Abe Dillon wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr"><font color="#741b47">On 15.02.2017, 20:39 Kyle
Lahnakoski wrote:<br>
</font>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span style="font-size:12.8px"><font color="#741b47">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).</font></span></blockquote>
<div><br>
</div>
<div>Again, isn't that what Filters are for? I mean the
documentation says:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><font face="arial,
helvetica, sans-serif" color="#274e13"><code class="m_-7941316021455768539gmail-docutils m_-7941316021455768539gmail-literal" style="background-color:rgb(236,240,243);padding:0px 1px;border-radius:3px;text-align:justify"><span class="m_-7941316021455768539gmail-pre">Filters</span></code><span style="text-align:justify"> can be used by </span><code class="m_-7941316021455768539gmail-docutils m_-7941316021455768539gmail-literal" style="background-color:rgb(236,240,243);padding:0px 1px;border-radius:3px;text-align:justify"><span class="m_-7941316021455768539gmail-pre">Handlers</span></code><span style="text-align:justify"> and </span><code class="m_-7941316021455768539gmail-docutils m_-7941316021455768539gmail-literal" style="background-color:rgb(236,240,243);padding:0px 1px;border-radius:3px;text-align:justify"><span class="m_-7941316021455768539gmail-pre">Loggers</span></code><span style="text-align:justify"> for more sophisticated
filtering than is provided by levels.</span> </font></blockquote>
<div><br>
</div>
</div>
</div>
</blockquote>
<br></span>
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.<br>
</div>
<br>______________________________<wbr>_________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/<wbr>codeofconduct/</a><br></blockquote></div><br></div>