This is an attempt to keep the structure of LogMessage in the GELF output. I use a standard default argument to json.dumps to fall back to __repr__ wherever it's impossible to convert object to JSON.
In addition, this PR also tries to solve the issue in #38 by applying unicode(..., errors=replace) recursively throughout the message. I'm sure some corner cases left, but in most tricky scenarios it should work well.
Solution should work both on py2.x and py3.x. Would love to have it merged. Thanks!
This is an attempt to keep the structure of LogMessage in the GELF output. I use a standard
default
argument tojson.dumps
to fall back to__repr__
wherever it's impossible to convert object to JSON.In addition, this PR also tries to solve the issue in #38 by applying
unicode(..., errors=replace)
recursively throughout the message. I'm sure some corner cases left, but in most tricky scenarios it should work well.Solution should work both on py2.x and py3.x. Would love to have it merged. Thanks!