graylog-labs / gelf-rb

Ruby GELF library (Graylog Extended Log Format)
https://rubygems.org/gems/gelf
MIT License
153 stars 104 forks source link

GELF::Notifier#serialize_hash fails when attempting to read 'rack.errors' #44

Open rthbound opened 8 years ago

rthbound commented 8 years ago

Hi, I'm using graylog with rails 5 (edge)... I've found that GELF::Notifier now fails here: https://github.com/Graylog2/gelf-rb/blob/master/lib/gelf/notifier.rb#L254 ...

Tracing the code, I see that the error occurs when calling #as_json on #IO:

IOError: not opened for reading.

I believe this is because we're attempting to read $stderr, which is write-only.

ping @joschi

rthbound commented 8 years ago

@joschi any ideas?

rthbound commented 8 years ago

Pinging a few others: @bernd @dennisoelkers @edmundoa @mariussturm (please don't hate me :smile: )

Is this a new problem? Have you guys coded around this previously? As far as I can see, rack.errors has always held a STDERR stream (and has always been write-only). Was there some code written to skip over rack.errors, to rescue from IOErrors, something else?

Looking forward to using graylog when rails5 comes out, but it looks like this error will prevent that.

Edit: another possibility is that #as_json's behavior has changed (maybe it's become less forgiving)

milgner commented 8 years ago

Hi @rthbound,

thank you for bringing this to our attention! Do you happen to have a full backtrace of the problem at hand? It would be interesting to see how the rack.errors find their way into the hash at all since I'd guess that this gem is not the only logger that might have trouble working with those.

rthbound commented 8 years ago

@milgner apologies for the delay. It looks like others may be noticing this too, outside of the gelf-rb world. rails/rails/issues/26132