Sha256: 7e8a110aed81167db0e1abb54218528292acbc33fcf7682f97fd9acfc763dc0b
Contents?: true
Size: 1.27 KB
Versions: 4
Compression:
Stored size: 1.27 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, stats, log log.info event: 'filter-loading' log.debug event: 'filter-config', config: config config ||= {} # Allow for nil config @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, log) end end log.info event: 'filter-fully-loaded' end def apply event raise 'Event does not have a "type" field' unless event[:type] type = event[:type].to_sym # 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 private def filtered event, options if remove_field = options[:remove_field] event.delete remove_field.to_sym end event end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
anschel-0.6.5 | lib/anschel/filter.rb |
anschel-0.6.4 | lib/anschel/filter.rb |
anschel-0.6.3 | lib/anschel/filter.rb |
anschel-0.6.2 | lib/anschel/filter.rb |