Sha256: 5e9ccb2c8f6e97bdf8673325da1596edec00c7f55c3b2e81d4bcb04a18c64dbf
Contents?: true
Size: 701 Bytes
Versions: 1
Compression:
Stored size: 701 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 opts = taggers.extract_options! @taggers = taggers.flatten @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['HTTP_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.6.0 | lib/silencer/logger.rb |