Sha256: a0140303798127765913c71024ff129eb588be3ce417ddd1d6e2abc0c4166320

Contents?: true

Size: 950 Bytes

Versions: 2

Compression:

Stored size: 950 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.to_hash.awesome_inspect + NL)
  end # def encode_default

  def encode_with_metadata(event)
    @on_event.call(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.2 lib/logstash/codecs/rubydebug.rb
logstash-codec-rubydebug-0.1.1 lib/logstash/codecs/rubydebug.rb