Class: LogStash::Codecs::Plain

Inherits:
Base
  • Object
show all
Defined in:
lib/logstash/codecs/plain.rb

Overview

The “plain” codec is for plain text with no delimiting between events.

This is mainly useful on inputs and outputs that already have a defined framing in their transport protocol (such as zeromq, rabbitmq, redis, etc)

Instance Method Summary collapse

Instance Method Details

#decode(data) {|LogStash::Event.new("message" => @converter.convert(data))| ... } ⇒ Object

Yields:

  • (LogStash::Event.new("message" => @converter.convert(data)))

34
35
36
# File 'lib/logstash/codecs/plain.rb', line 34

def decode(data)
  yield LogStash::Event.new("message" => @converter.convert(data))
end

#encode(event) ⇒ Object


39
40
41
42
43
44
45
# File 'lib/logstash/codecs/plain.rb', line 39

def encode(event)
  if event.is_a?(LogStash::Event) and @format
    @on_event.call(event, event.sprintf(@format))
  else
    @on_event.call(event, event.to_s)
  end
end

#registerObject


28
29
30
31
# File 'lib/logstash/codecs/plain.rb', line 28

def register
  @converter = LogStash::Util::Charset.new(@charset)
  @converter.logger = @logger
end