graypy icon indicating copy to clipboard operation
graypy copied to clipboard

JSON Serialization Improvements for GELFRabbitHandler

Open displaced opened this issue 7 years ago • 2 comments

  • Made smarter_repr smarter (handles enums and tries to use dict for other objects. Needed for my use-case of logging data from the nameko-tracer extension to the nameko microservice framework)

  • Told GELFRabbitHandler to use smarter_repr when serialising its final object

displaced avatar Oct 10 '18 15:10 displaced

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__)?

severb avatar Oct 10 '18 18:10 severb

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.

displaced avatar Oct 11 '18 10:10 displaced