Sha256: 20d4ff17b5b7c8d4cfa95e5369c9f17a0563031b833400308bad847b3c00383b

Contents?: true

Size: 1.06 KB

Versions: 20

Compression:

Stored size: 1.06 KB

Contents

# encoding: utf-8
require "logstash/namespace"
require "logstash/event"
require "logstash/plugin"
require "logstash/logging"

# This is the base class for logstash codecs.
module LogStash::Codecs; class Base < LogStash::Plugin
  include LogStash::Config::Mixin
  config_name "codec"

  def initialize(params={})
    super
    config_init(params)
    register if respond_to?(:register)
  end

  public
  def decode(data)
    raise "#{self.class}#decode must be overidden"
  end # def decode

  alias_method :<<, :decode

  public
  def encode(event)
    raise "#{self.class}#encode must be overidden"
  end # def encode

  public 
  def close; end;

  # @param block [Proc(event, data)] the callback proc passing the original event and the encoded event
  public
  def on_event(&block)
    @on_event = block
  end

  public
  def flush(&block)
    # does nothing by default.
    # if your codec needs a flush method (like you are spooling things)
    # you must implement this.
  end

  public
  def clone
    return self.class.new(params)
  end
end; end # class LogStash::Codecs::Base

Version data entries

20 entries across 19 versions & 2 rubygems

Version Path
logstash-core-2.1.3-java lib/logstash/codecs/base.rb
logstash-core-2.1.2-java lib/logstash/codecs/base.rb
logstash-core-2.1.2.snapshot1-java lib/logstash/codecs/base.rb
logstash-core-2.2.0.snapshot2-java lib/logstash/codecs/base.rb
logstash-core-2.1.1-java lib/logstash/codecs/base.rb
logstash-core-2.1.0-java lib/logstash/codecs/base.rb
logstash-core-2.1.0.snapshot4-java lib/logstash/codecs/base.rb
logstash-core-2.1.0.snapshot3-java lib/logstash/codecs/base.rb
logstash-input-beats-2.0.2 vendor/jruby/1.9/gems/logstash-core-2.0.1-java/lib/logstash/codecs/base.rb
logstash-input-beats-2.0.2 vendor/jruby/1.9/gems/logstash-core-2.0.0-java/lib/logstash/codecs/base.rb
logstash-core-2.0.1-java lib/logstash/codecs/base.rb
logstash-core-2.1.0.snapshot2-java lib/logstash/codecs/base.rb
logstash-core-2.1.0.snapshot1-java lib/logstash/codecs/base.rb
logstash-core-2.0.1.snapshot1-java lib/logstash/codecs/base.rb
logstash-core-2.0.0-java lib/logstash/codecs/base.rb
logstash-core-2.0.0.rc1-java lib/logstash/codecs/base.rb
logstash-input-beats-0.9.2 vendor/jruby/1.9/gems/logstash-core-2.0.0.beta3-java/lib/logstash/codecs/base.rb
logstash-input-beats-0.9.1 vendor/jruby/1.9/gems/logstash-core-2.0.0.beta3-java/lib/logstash/codecs/base.rb
logstash-core-2.0.0.beta3-java lib/logstash/codecs/base.rb
logstash-core-2.0.0.beta2-java lib/logstash/codecs/base.rb