<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Mar 26, 2012, at 10:38 AM, <a href="mailto:exarkun@twistedmatrix.com">exarkun@twistedmatrix.com</a> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Menlo; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span class="Apple-style-span" style="font-family: monospace; ">I agree with just about everything here, except I think we should be<span class="Apple-converted-space">&nbsp;</span><br>able to do better than the `format="opaque string"´ part.<br></span></span></blockquote><div><br></div><div>In principle I agree, but I'm not sure about how to do that _exactly now_. &nbsp;Whereas today, immediately, all log messages could be written in the style I suggested and it would be a big improvement.</div><div><br></div><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Menlo; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span class="Apple-style-span" style="font-family: monospace; ">Logging in the style you outlined here preserves the structure of the<span class="Apple-converted-space">&nbsp;</span><br>information, but it omits any consistent way to identify what the<span class="Apple-converted-space">&nbsp;</span><br>structure is. &nbsp;It seems to leave only two possibilities:<br><br>&nbsp;- Compare the format string to certain well-known format strings and<span class="Apple-converted-space">&nbsp;</span><br>use a match (if found) to make decisions based on a priori knowledge<span class="Apple-converted-space">&nbsp;</span><br>about the additional items in the log event.<br></span></span></blockquote><div><br></div><div>Previous (limited) experience with internationalization efforts lead me to believe that looking at well-known format strings to determine meaning is the state of the art.</div><div><br></div><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Menlo; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span class="Apple-style-span" style="font-family: monospace; ">&nbsp;- Compare the set of keys in the log event to certain well-known sets<span class="Apple-converted-space">&nbsp;</span><br>and use a match there to make the same kind of decision.<br><br>Neither of these sounds like a good thing.<br></span></span></blockquote><div><br></div><div>Still, a pretty substantial improvement over running a regex over a string in a quasi-structured log file after the fact (IMHO).</div><br><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Menlo; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; font-size: medium; "><span class="Apple-style-span" style="font-family: monospace; ">Divmod experimented with marking log events with interfaces that<span class="Apple-converted-space">&nbsp;</span><br>documented the structure and semantics of the log event carrying them.<span class="Apple-converted-space">&nbsp;</span><br>This didn't get very far, and perhaps had problems of its own, but even<span class="Apple-converted-space">&nbsp;</span><br>it seemed preferable to either of the above options.<br></span></span></blockquote></div><br><div>What I'd really like to do is to have some kind of log object built up like this:</div><div><br></div><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;"><div>logger = Logger(module=__name__)</div><div><br></div><div><br></div><div>class DebugFoo(logger.message()):</div><div>&nbsp; &nbsp;"""wouldn't it be great if such messages were explained in detail"""</div><div>&nbsp; &nbsp;audience=developers; importance=medium;&nbsp;format="foo %(foo)d happened";</div><div>&nbsp; &nbsp;logID=UUID('7dc1c45b-4eb7-4a3f-b751-ee6b500f11ce')</div><div>&nbsp; &nbsp;anythingElseInteresting="otherstuff"</div><div><br></div><div>def onFoo(someFoo):</div><div>&nbsp; &nbsp; DebugFoo.emit(foo=7)</div></blockquote><br><div>and while this isn't hard to implement, it's also not implemented already, but the format= stuff is. &nbsp;So my suggestion was not intended to say we should stop here, but rather, while we're figuring out better stuff to do, nobody should ever write a 'log.msg("some static " + thing)' again :).</div><div><br></div><div>-glyph</div><div><br></div></body></html>