severb / graypy

Python logging handler for Graylog that sends messages in GELF (Graylog Extended Log Format).
https://www.graylog.org/
BSD 3-Clause "New" or "Revised" License
258 stars 90 forks source link

Get rid of custom object-to-json converter #48

Closed imankulov closed 9 years ago

imankulov commented 9 years ago

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!

severb commented 9 years ago

This looks great, thanks!