Class: LogStash::Codecs::Line
- Defined in:
- lib/logstash/codecs/line.rb
Overview
Line-oriented text data.
Decoding behavior: Only whole line events will be emitted.
Encoding behavior: Each event will be emitted with a trailing newline.
Constant Summary
Constants included from LogStash::Config::Mixin
LogStash::Config::Mixin::CONFIGSORT
Instance Attribute Summary
Attributes included from LogStash::Config::Mixin
Attributes inherited from Plugin
Instance Method Summary collapse
Methods inherited from Base
#clone, #initialize, #on_event, #teardown
Methods included from LogStash::Config::Mixin
Methods inherited from Plugin
#eql?, #finished, #finished?, #hash, #initialize, #inspect, lookup, #reload, #running?, #shutdown, #teardown, #terminating?, #to_s
Constructor Details
This class inherits a constructor from LogStash::Codecs::Base
Instance Method Details
#decode(data) ⇒ Object
35 36 37 38 39 |
# 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) ⇒ Object
50 51 52 53 54 55 56 |
# 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 |