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)))


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

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

#encode(event) ⇒ Object



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

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

#registerObject



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

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