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

JSON Serialization Improvements for GELFRabbitHandler #91

Open displaced opened 5 years ago

displaced commented 5 years ago
severb commented 5 years ago

I don't oppose including the enum but I fear that the __dict__ case changes the log structure for others that use the current repr functionality. Thoughts?

Nit: would repr(dir(obj)) be preferrable to repr(obj.__dict__)?

displaced commented 5 years ago

I don't oppose including the enum but I fear that the __dict__ case changes the log structure for others that use the current repr functionality. Thoughts?

Ah, yes -- definitely agree. Would you be happy with wrapping the original routine in a try/except, and putting the new stuff into the except block?

[EDIT: Apologies, I was answering from memory -- the serialisation doesn't happen in that function, so the exception won't happen there -- I'll have another think!]

Nit: would repr(dir(obj)) be preferrable to repr(obj.__dict__)?

I'll give it a go -- I was concerned that dir() might grab too much detail about the object, but let's see what it looks like.