Sha256: b4dbcc9bdec58338732c6c0dc2c100b1628dde293d53f8da5db34f90ec1cefcd

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

# encoding: utf-8
require "logstash/filters/base"
require "logstash/namespace"
require "htmlentities"

class LogStash::Filters::HTMLEntities < LogStash::Filters::Base
    config_name "htmlentities"

    # The field to perform filter
    #
    config :source, :validate => :string, :default => "message"

    # The name of the container to put the result
    #
    config :target, :validate => :string, :default => "message"


    public
    def register
      @coder = HTMLEntities.new
    end # def register

  public
  def filter(event)

    if @source
      # Replace the event message with our message as configured in the
      # config file.
      event.set(@target, @coder.decode(event.get(@source)))
      # correct debugging log statement for reference
      # using the event.get API
      @logger.debug? && @logger.debug("#{@target} is now: #{event.get(@target)}")
    end

    # filter_matched should go in the last line of our successful code
    filter_matched(event)
  end # def filter
end # class LogStash::Filters::Example

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
logstash-filter-htmlentities-0.1.0 lib/logstash/filters/htmlentities.rb
logstash-filter-htmlentities-0.1.0.pre.alpha lib/logstash/filters/htmlentities.rb