On Thu, Jun 13, 2013 at 7:14 PM, Glyph <gl...@twistedmatrix.com> wrote:
> For a long time, there's been consensus among at least a few core Twisted > developers that log messages ought to be specified in terms of a format > message and several relevant keyword arguments, so that tools can extract > the values of the keyword arguments without parsing ad-hoc messages or using > regexes. In other words, like this: > > log.msg(format="Foo happened. Relevant information includes: " > "bar=%(bar)s baz=%(baz)s boz=%(boz)s", > bar=bar, baz=baz, boz=boz) Mmm... which is the problem with doing: log.msg("Foo happened. Relevant information includes: " "bar=%s baz=%s boz=%s", bar, baz, boz) Is way more readable, and in the practice the code will just need to do something like: def msg(format_string, *args): try: line = format_string % args except: # something clever No regexes involved, and very cheap in the case where it works. And this is a personal opinion: the "working way" (where programmed coded all ok) should be as cheap as possible. If something is wrong with the logging line, it must not crash, and I don't care if it's expensive, but that line will be fixed, and will work ok, and from there to the future it will be cheap. Thanks! -- . Facundo Blog: http://www.taniquetil.com.ar/plog/ PyAr: http://www.python.org/ar/ Twitter: @facundobatista _______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python