Sha256: 6e9407f6ae7e5571d71b9bebe81e4fea8c3f57c80a1cd3c15e80fb19aa82ff19

Contents?: true

Size: 1.16 KB

Versions: 10

Compression:

Stored size: 1.16 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

  # AWESOME_OPTIONS = {:color => {:logstash_timestamp => :green}}
  # disabled options, awesome_print coloring option is buggy and only occurs once and it cannot be tested.
  AWESOME_OPTIONS = {}

  def register
    require "awesome_print"
    AwesomePrint.defaults = AWESOME_OPTIONS

    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

10 entries across 10 versions & 1 rubygems

Version Path
logstash-codec-rubydebug-3.0.6 lib/logstash/codecs/rubydebug.rb
logstash-codec-rubydebug-3.0.5 lib/logstash/codecs/rubydebug.rb
logstash-codec-rubydebug-3.0.4 lib/logstash/codecs/rubydebug.rb
logstash-codec-rubydebug-3.0.3 lib/logstash/codecs/rubydebug.rb
logstash-codec-rubydebug-3.0.2 lib/logstash/codecs/rubydebug.rb
logstash-codec-rubydebug-3.0.1 lib/logstash/codecs/rubydebug.rb
logstash-codec-rubydebug-3.0.0 lib/logstash/codecs/rubydebug.rb
logstash-codec-rubydebug-2.0.7 lib/logstash/codecs/rubydebug.rb
logstash-codec-rubydebug-2.0.5 lib/logstash/codecs/rubydebug.rb
logstash-codec-rubydebug-2.0.4 lib/logstash/codecs/rubydebug.rb