Sha256: 832e24131e2d8ebd2f794ca1a5e354569fc05dbf020d9a4d6b645040ae643e53

Contents?: true

Size: 964 Bytes

Versions: 2

Compression:

Stored size: 964 Bytes

Contents

# encoding: utf-8
require "logstash/codecs/base"

# The rubydebug codec will output your Logstash event data using
# the Ruby Awesome Print library.
#
class LogStash::Codecs::RubyDebug < LogStash::Codecs::Base
  config_name "rubydebug"
  milestone 3

  # Should the event's metadata be included?
  config :metadata, :validate => :boolean, :default => false

  def register
    require "awesome_print"
    if @metadata
      @encoder = method(:encode_with_metadata)
    else
      @encoder = method(:encode_default)
    end
  end

  public
  def decode(data)
    raise "Not implemented"
  end # def decode

  public
  def encode(event)
    @encoder.call(event)
  end

  def encode_default(event)
    @on_event.call(event, event.to_hash.awesome_inspect + NL)
  end # def encode_default

  def encode_with_metadata(event)
    @on_event.call(event, event.to_hash_with_metadata.awesome_inspect + NL)
  end # def encode_with_metadata

end # class LogStash::Codecs::Dots

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
logstash-codec-rubydebug-0.1.4 lib/logstash/codecs/rubydebug.rb
logstash-codec-rubydebug-0.1.3 lib/logstash/codecs/rubydebug.rb