Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions lib/logstash/codecs/multiline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,25 @@ def accept(listener)
end

def decode(text, &block)
text = @converter.convert(text)
text.split("\n").each do |line|
parts = text.split("\n")

# oftentimes the sysread done by the input plugin
# is not perfectly aligned with newlines. In these
# cases (no newline at string ending) we keep that part
# as a carry over and will reattach it at the next
# decode call

if @carry_over
parts[0] = @carry_over + parts[0]
@carry_over = nil
end

unless text =~ /\n\Z/
@carry_over = parts.pop
end

parts.each do |line|
line = @converter.convert(line)
match = @grok.match(line)
@logger.debug("Multiline", :pattern => @pattern, :text => line,
:match => !match.nil?, :negate => @negate)
Expand Down