Sha256: 4df7b37f1aecc24d94219b04f9f956cfbac8238535c0faee0c8dd4751a5ba88d
Contents?: true
Size: 726 Bytes
Versions: 15
Compression:
Stored size: 726 Bytes
Contents
require 'logger' module FilteringLogger attr_reader :filters def filters=(f) raise ArgumentError, "Must provide an array" unless f.is_a?(Array) @filters = f end def add(s, m = nil, p = nil, &blk) p ||= @progname if @filters && p @filters.each do |re, sev| if re === p if s < sev return true else # We force the severity to nil for this call to override # the logger's default severity filtering logic, because # messages without a severity are always logged return super(nil, m, p, &blk) end end end end super end alias log add end Logger.prepend(FilteringLogger)
Version data entries
15 entries across 15 versions & 1 rubygems