Skip to content

Instantly share code, notes, and snippets.

@athurg
Created May 9, 2017 08:55
Show Gist options
  • Save athurg/1175f58bc35dfcc1822bf5af4579a0ed to your computer and use it in GitHub Desktop.
Save athurg/1175f58bc35dfcc1822bf5af4579a0ed to your computer and use it in GitHub Desktop.
用于将部分Rails请求日志屏蔽掉的代码
# encoding: utf-8
# Place into Rails.root/config/initializers
Rails::Rack::Logger.class_eval do
def call_with_quiet_assets(env)
previous_level = Rails.logger.level
Rails.logger.level = Logger::FATAL if env['PATH_INFO']=="/silence/request"
call_without_quiet_assets(env).tap do
Rails.logger.level = previous_level
end
end
alias_method_chain :call, :quiet_assets
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment