dwbutler / logstash-logger

Ruby logger that writes logstash events
MIT License
456 stars 118 forks source link

Exception when trying to encode message #158

Open stefanchrobot opened 4 years ago

stefanchrobot commented 4 years ago

The LogStashLogger fails when encoding some events. Note that the error happens upstream in the logstash-event gem, but I couldn't find where to report that.

Reproduction:

s = "x\xc3x".force_encoding('ASCII-8BIT')

l = Logger.new(STDOUT)
l.info(s)
# fine
# I, [2020-04-06T09:16:57.787645 #39066]  INFO -- : x�x

ll = LogStashLogger.new(type: :stdout)
ll.info(s)
# explodes
# Encoding::UndefinedConversionError: "\xC3" from ASCII-8BIT to UTF-8
# from /Users/stefan/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/logstash-event-1.2.02/lib/logstash/event.rb:169:in `to_json'

Expected result: Handle invalid codepoints like the standard Logger.

Actual result: Exception.

RomanSolianik commented 2 years ago

Have the same issue. Any updates on it?