Sha256: 5a2094b6fded2146797098b469ea94e6c4735aa4050cbcb9a32ebe4f938d8a6a

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

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"

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

  def register
    require "awesome_print"
    AwesomePrint.defaults = { :color => { :logstash_timestamp => :green } }
    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

1 entries across 1 versions & 1 rubygems

Version Path
logstash-codec-rubydebug-2.0.3 lib/logstash/codecs/rubydebug.rb