Sha256: 63818d6d5f15e101dfa0dcaa5810a2521b704950ec775760d900d5db7bef8b39
Contents?: true
Size: 1.34 KB
Versions: 7
Compression:
Stored size: 1.34 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' require_relative 'filter/tag' require_relative 'filter/debug' module Anschel class Filter attr_reader :filters def initialize config, stats, log log.info event: 'filter-loading' log.info 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, stats, 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
7 entries across 7 versions & 1 rubygems