
On May 10, 2016, at 4:23 PM, Daniel Sutcliffe <dansut@gmail.com> wrote:
Thanks for all the hints and suggestions guys, this was far simpler than I thought it would be and the results are exactly what I imagined without too much effort.
On Sat, May 21, 2016 at 9:44 PM, Glyph <glyph@twistedmatrix.com> wrote:
Fantastic!
[...]
Glyph: The code below is I'm sure far from perfect, and it doesn't take your advice and convert the msg into a twisted format string, it takes the simpler approach of letting the Logging record pre-format using the getMessage() method. I'm sure there are loads of edge cases it could cope with better with maybe it is a start of something that could be included in Twisted.
The main reason I wanted to do the format-string translation is that it would allow the key/value pairs to be stored according to the same idiom that Twisted uses, and therefore be serialized to jsonFileLogObserver and consequently things like LogStash / ElasticSearch.
I kept the format-string args within a dictionary under the args kwarg to emit() for exactly the reasons you gave above but felt that translating a %-encoded string into the new-style that twisted.logger uses was likely to make the example much more complicated, and was frankly beyond my limited needs. There's probably a simple way to do this in Python that I am not aware of yet though... [...]
But hopefully this all makes sense and this can be a start of something much more generically useful.
Yep! This is definitely something handy. Would you mind filing an issue for it?
I've created issue #8358 https://twistedmatrix.com/trac/ticket/8358 Which is hopefully what you were after - spent a bunch of time reading your impressive process and standards docs so I'm already sure that anything that finds itself in Twisted from this will probably be quite significantly different to this initial suggestion but I don't mind a bit of learning if someone is willing to give me a bit of mentoring me to get this into shape so it can be done as a PR. Cheers /dan -- Daniel Sutcliffe <dansut@gmail.com>