1
0
mirror of https://github.com/meineerde/rackstash.git synced 2025-10-17 14:01:01 +00:00

Return the normalized unchanged message from the Message encoder

This commit is contained in:
Holger Just 2017-09-29 23:40:02 +02:00
parent 59c94a8ecc
commit 3584244bc1
2 changed files with 4 additions and 10 deletions

View File

@ -19,12 +19,11 @@ module Rackstash
include Rackstash::Encoders::Helpers::Message
# @param event [Hash] a log event as produced by the {Flow}
# @return [String] the `"message"` field of the event. Trailing whitespace
# will be removed.
# @return [String] the `"message"` field of the event
def encode(event)
normalize_message(event)
event[FIELD_MESSAGE].rstrip
event[FIELD_MESSAGE]
end
end
end

View File

@ -14,13 +14,8 @@ describe Rackstash::Encoders::Message do
describe '#encode' do
it 'gets the message from the event hash' do
event = { 'hello' => 'world', 'message' => ["hello\n", "world"] }
expect(encoder.encode(event)).to eql "hello\nworld"
end
it 'rstrips the message' do
event = { 'message' => "\n\t \nline1\nline2\n \n\t\n" }
expect(encoder.encode(event)).to eql "\n\t \nline1\nline2"
event = { 'hello' => 'world', 'message' => ["\n\t \nline1\n", "line2\n \n\t\n"] }
expect(encoder.encode(event)).to eql "\n\t \nline1\nline2\n \n\t\n"
end
end
end