<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 15 Feb 2017, at 02:39, Kyle Lahnakoski <<a href="mailto:klahnakoski@mozilla.com" class="">klahnakoski@mozilla.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">
<meta content="text/html; charset=windows-1252" http-equiv="Content-Type" class="">
<div bgcolor="#FFFFFF" text="#000000" class="">
<br class="">
<div class="moz-cite-prefix">On 2017-02-14 19:51, Abe Dillon wrote:<br class="">
</div>
<blockquote cite="mid:CAKr=oZvxfjOSxRvpN9twQ2BuN=p247HGWs_9p1ExxOkk8ahyHQ@mail.gmail.com" type="cite" class="">
<div dir="ltr" class="">
<div style="font-size:12.8px" class=""><font color="#9900ff" class=""> </font><font color="#741b47" class=""> The point is that the cost of creating the
msg argument can be very high.</font></div>
<div style="font-size:12.8px" class=""><font color="#741b47" class=""><br class="">
</font></div>
<div style="font-size:12.8px" class=""><font color="#741b47" class=""> At the
point that logging decides to skip output it is to late to
save the cost of creating the arg tuple.</font><br class="">
<br class="">
This sounds like an optimization that's sufficiently rare and
complex to warrant a custom fix or a 3rd party library.<br class="">
<br class="">
<font color="#741b47" class=""> <span style="font-size:12.8px" class="">Not
that it is relivent for this idea bit logging's levels are
too course for logging in complete</span></font></div>
<div style="font-size:12.8px" class=""><span style="font-size:12.8px" class=""><font color="#741b47" class=""> applications. The app I am working on
at the moment has 20 seperate debug categories</font></span></div>
<div style="font-size:12.8px" class=""><span style="font-size:12.8px" class=""><font color="#741b47" class=""> that are independently enabled.</font></span></div>
<div class=""><br class="">
Holy balls! That sounds like a tortured use of log levels!</div>
</div>
</blockquote>
<br class="">
That's a funny expression. :)<br class="">
<br class="">
I have not got to the point of 20 debug categories in a single file,
but I easily have 20+ debug categories in an application. I
previously suggested wrapping the expensiveFunction in a lambda, but
that is not what I do. I prefer using explicit logging switches:<br class="">
<br class="">
____if DEBUG_FEATURE_A: <br class="">
________debugLog(msg, expensiveFunction() )<br class="">
____if DEBUG_FEATURE_B: <br class="">
________debugLog(msg2, expensiveFunction2() )<br class="">
<br class="">
The benefit is clarity at the expense of more lines, while still
avoiding the expensiveFunction() when I can. Using switches result
in a smaller log file, because logging is focused on the feature,
plus, these switches can still be dynamically set from outside the
module.<br class=""></div></div></blockquote><div><br class=""></div><div>I would like to avoid the if so that the code is more compact if possible.</div><br class=""><blockquote type="cite" class=""><div class=""><div bgcolor="#FFFFFF" text="#000000" class="">
<br class="">
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).<br class=""></div></div></blockquote><div><br class=""></div><div>Well said that is indeed the issue with the logger module as is.</div><br class=""><blockquote type="cite" class=""><div class=""><div bgcolor="#FFFFFF" text="#000000" class="">
<br class="">
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</div></div></blockquote><div><br class=""></div><div>It is not clear to me from one reading is PEP 532 will allow a class with __then__ and __else to do what I want.</div><div><br class=""></div><div>Would it be something like this:</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>if not debugLog and (expensive(), args())</div><div><br class=""></div><div>Does debugLog get passed the tuple in the __then__?</div><div><br class=""></div><div><br class=""></div><div>Barry</div><div><br class=""></div><blockquote type="cite" class=""><div class=""><div bgcolor="#FFFFFF" text="#000000" class="">_______________________________________________</div>Python-ideas mailing list<br class=""><a href="mailto:Python-ideas@python.org" class="">Python-ideas@python.org</a><br class="">https://mail.python.org/mailman/listinfo/python-ideas<br class="">Code of Conduct: http://python.org/psf/codeofconduct/</div></blockquote></div><br class=""></body></html>