<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="gmail-docutils gmail-literal" style="background-color:rgb(236,240,243);padding:0px 1px;border-radius:3px;text-align:justify"><span class="gmail-pre">Filters</span></code><span style="text-align:justify"> can be used by </span><code class="gmail-docutils gmail-literal" style="background-color:rgb(236,240,243);padding:0px 1px;border-radius:3px;text-align:justify"><span class="gmail-pre">Handlers</span></code><span style="text-align:justify"> and </span><code class="gmail-docutils gmail-literal" style="background-color:rgb(236,240,243);padding:0px 1px;border-radius:3px;text-align:justify"><span class="gmail-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> <span style="color:rgb(116,27,71)">On 15.02.2017, 20:39 Kyle Lahnakoski wrote:</span></div></div><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">But to stick to the theme of language features: I believe there is a previous thread that touches on a solution to the original posters problem: "Alternative to PEP 532: delayed evaluation of expressions"</font></span></blockquote><div><br></div><div>That sounds interesting. It sounds a lot like a future. I like that it's a generalization of the problem (lazy expression evaluation) instead of a narrow problem (conditionally logging expensive messages) that is otherwise easily addressed by custom logic.<br><br><font color="#741b47">On 16.02.2017, 5:47 Barry Scott 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"><font color="#741b47"><span style="font-size:12.8px">__repr__ is interesting however.</span><br style="font-size:12.8px"><br style="font-size:12.8px"><span style="font-size:12.8px">Typically I describe in a string why the value is being logged. That means</span><br style="font-size:12.8px"><span style="font-size:12.8px">that the object is always a string. I cannot recall using debugLog( obj )</span><br style="font-size:12.8px"><span style="font-size:12.8px">in production.</span></font><br></blockquote><br>Loggers can handle that, though. You can easily write:<br></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">>>> log.debug("log description: val_1=%r, val_2=%s", 3.14, 100)</font></div><div><br>Instead of</div><div><br class="gmail-Apple-interchange-newline"><font face="monospace, monospace">>>> log.debug(</font><span style="font-family:monospace,monospace">"log description: val_1=%r, val_2=%s"</span><font face="monospace, monospace"> % (3.14, 100))</font><br><br>The former won't construct the full message if the log level is higher than debug. It won't repr 3.14 or stringify 100.<br><br>you can wrap functions in an object that only evaluates them when __repr__ and/or __str__ is called. It doesn't save you much time, because now you're writing a custom class instead of a custom function, I suppose.<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 15, 2017 at 10:46 AM, Sven R. Kunze <span dir="ltr"><<a href="mailto:srkunze@mail.de" target="_blank">srkunze@mail.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 15.02.2017 12:55, Barry Scott wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
The lazy eval sound like a generator.<br>
<br>
</blockquote>
<br></span>
Exactly my thought.<span class="HOEnZb"><font color="#888888"><br>
<br>
<br>
Sven</font></span><div class="HOEnZb"><div class="h5"><br>
______________________________<wbr>_________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/mailma<wbr>n/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/codeofco<wbr>nduct/</a><br>
</div></div></blockquote></div><br></div>