Skip to content

Commit

Permalink
Normalize log lines to UTF-8
Browse files Browse the repository at this point in the history
  • Loading branch information
meineerde committed Aug 24, 2016
1 parent 470163d commit 1b92cf1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/rackstash/buffered_logger.rb
Expand Up @@ -243,7 +243,10 @@ def normalized_message(logs=[])
msg = line[:message].to_s.gsub(/[\n\r]/, "\n")
# remove any leading newlines and a single trailing newline
msg = msg.sub(/\A\n+/, '').sub(/\n\z/, '')
"[#{Severities[line[:severity]]}] ".rjust(10) + msg
msg = "[#{Severities[line[:severity]]}] ".rjust(10) + msg
# Normalize the log line to UTF-8
msg.encode!(Encoding::UTF_8, invalid: :replace, undef: :replace) if msg.respond_to?(:encode!)
msg
end.join("\n")
end

Expand Down

0 comments on commit 1b92cf1

Please sign in to comment.