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.
Public Instance Methods
decode(data) { |event("message" => convert)| ... }
click to toggle source
# File lib/logstash/codecs/line.rb, line 35 def decode(data) @buffer.extract(data).each do |line| yield LogStash::Event.new("message" => @converter.convert(line)) end end
encode(data)
click to toggle source
# File lib/logstash/codecs/line.rb, line 50 def encode(data) if data.is_a? LogStash::Event and @format @on_event.call(data.sprintf(@format) + "\n") else @on_event.call(data.to_s + "\n") end end
flush(&block)
click to toggle source
# File lib/logstash/codecs/line.rb, line 42 def flush(&block) remainder = @buffer.flush if !remainder.empty? block.call(LogStash::Event.new({"message" => remainder})) end end
register()
click to toggle source
# File lib/logstash/codecs/line.rb, line 27 def register require "logstash/util/buftok" @buffer = FileWatch::BufferedTokenizer.new @converter = LogStash::Util::Charset.new(@charset) @converter.logger = @logger end