Sha256: 13f48bfe1ed26c3f26c08ddaf16c99efb37c3c0f35e4727588929ea461495221
Contents?: true
Size: 1.1 KB
Versions: 1
Compression:
Stored size: 1.1 KB
Contents
require_relative 'filter/convert' require_relative 'filter/gsub' require_relative 'filter/index' require_relative 'filter/parse' require_relative 'filter/scan' require_relative 'filter/stamp' module Anschel class Filter attr_reader :filters def initialize config, log @filters = Hash.new { |h,k| h[k] = [] } config.each do |event_type, filter_defns| filter_defns.each do |filter_defn| filter_type = filter_defn.keys.first filter_conf = filter_defn[filter_type] @filters[event_type] << self.send(filter_type, filter_conf) end end log.info event: 'filter-loaded' end def apply event raise 'Event does not have a "type" field' unless event[:type] type = event[:type].dup # In case of modification filters[:_before].each { |f| f.call event } filters[type].each { |f| f.call event } filters[:_after].each { |f| f.call event } event end def filtered event, options if remove_field = options[:remove_field] event.delete remove_field end event end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
anschel-0.1.0 | lib/anschel/filter.rb |