Sha256: ca9095c1f0c19ad9753bc22786267afecff8e785c476e35c3dac489d0f2d224e
Contents?: true
Size: 689 Bytes
Versions: 1
Compression:
Stored size: 689 Bytes
Contents
require 'rails/rack/logger' require 'active_support/core_ext/array/wrap' module Silencer class Logger < Rails::Rack::Logger def initialize(app, *taggers) @app = app @taggers = taggers opts = @taggers.extract_options! @silence = Array.wrap(opts[:silence]) end def call(env) old_logger_level = Rails.logger.level Rails.logger.level = ::Logger::ERROR if silence_request?(env) super ensure # Return back to previous logging level Rails.logger.level = old_logger_level end private def silence_request?(env) env['X-SILENCE-LOGGER'] || @silence.any? { |s| s === env['PATH_INFO'] } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
silencer-0.4.0 | lib/silencer/logger.rb |