<html>
<head>
<meta content="text/html; charset=windows-1252"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<br>
<div class="moz-cite-prefix">On 2017-02-14 19:51, Abe Dillon wrote:<br>
</div>
<blockquote
cite="mid:CAKr=oZvxfjOSxRvpN9twQ2BuN=p247HGWs_9p1ExxOkk8ahyHQ@mail.gmail.com"
type="cite">
<div dir="ltr">
<div style="font-size:12.8px"><font color="#9900ff"> </font><font
color="#741b47"> The point is that the cost of creating the
msg argument can be very high.</font></div>
<div style="font-size:12.8px"><font color="#741b47"><br>
</font></div>
<div style="font-size:12.8px"><font color="#741b47"> At the
point that logging decides to skip output it is to late to
save the cost of creating the arg tuple.</font><br>
<br>
This sounds like an optimization that's sufficiently rare and
complex to warrant a custom fix or a 3rd party library.<br>
<br>
<font color="#741b47"> <span style="font-size:12.8px">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"><span style="font-size:12.8px"><font
color="#741b47"> applications. The app I am working on
at the moment has 20 seperate debug categories</font></span></div>
<div style="font-size:12.8px"><span style="font-size:12.8px"><font
color="#741b47"> that are independently enabled.</font></span></div>
<div><br>
Holy balls! That sounds like a tortured use of log levels!</div>
</div>
</blockquote>
<br>
That's a funny expression. :)<br>
<br>
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>
<br>
____if DEBUG_FEATURE_A: <br>
________debugLog(msg, expensiveFunction() )<br>
____if DEBUG_FEATURE_B: <br>
________debugLog(msg2, expensiveFunction2() )<br>
<br>
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>
<br>
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>
<br>
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"<br>
<br>
<br>
<br>
<br>
<br>
</body>
</html>