class LogStash::Codecs::Line
Line-oriented text data.
Decoding behavior: Only whole line events will be emitted.
Encoding behavior: Each event will be emitted with a trailing newline.
Constants
- MESSAGE_FIELD
Public Class Methods
new(*params)
click to toggle source
Calls superclass method
# File lib/logstash/codecs/line.rb, line 35 def initialize(*params) super @original_field = ecs_select[disabled: nil, v1: '[event][original]'] end
Public Instance Methods
decode(data) { |new_event_from_line(line)| ... }
click to toggle source
# File lib/logstash/codecs/line.rb, line 50 def decode(data) @buffer.extract(data).each { |line| yield new_event_from_line(line) } end
encode(event)
click to toggle source
# File lib/logstash/codecs/line.rb, line 61 def encode(event) encoded = @format ? event.sprintf(@format) : event.to_s @on_event.call(event, encoded + @delimiter) end
flush(&block)
click to toggle source
# File lib/logstash/codecs/line.rb, line 54 def flush(&block) remainder = @buffer.flush if !remainder.empty? block.call new_event_from_line(remainder) end end
register()
click to toggle source
# File lib/logstash/codecs/line.rb, line 43 def register require "logstash/util/buftok" @buffer = FileWatch::BufferedTokenizer.new(@delimiter) @converter = LogStash::Util::Charset.new(@charset) @converter.logger = @logger end
Private Instance Methods
new_event_from_line(line)
click to toggle source
# File lib/logstash/codecs/line.rb, line 68 def new_event_from_line(line) message = @converter.convert(line) event = event_factory.new_event MESSAGE_FIELD => message event.set @original_field, message.dup.freeze if @original_field event end