Class: LogStash::Codecs::Plain

Inherits:
Base 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)

Constant Summary

Constants included from LogStash::Config::Mixin

LogStash::Config::Mixin::CONFIGSORT

Instance Attribute Summary

Attributes included from LogStash::Config::Mixin

#config, #original_params

Attributes inherited from Plugin

#logger, #params

Instance Method Summary collapse

Methods inherited from Base

#clone, #flush, #initialize, #on_event, #teardown

Methods included from LogStash::Config::Mixin

#config_init, included

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) {|LogStash::Event.new("message" => @converter.convert(data))| ... } ⇒ Object

Yields:



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

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

#encode(data) ⇒ Object



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

def encode(data)
  if data.is_a? LogStash::Event and @format
    @on_event.call(data.sprintf(@format))
  else
    @on_event.call(data.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