Created
May 1, 2013 15:31
-
-
Save jadon1979/5495996 to your computer and use it in GitHub Desktop.
Stop logging Assets and other particular messages.
A great example: An Ajax call checking a Queue every nSeconds and filling up the log with simple GET requests. Add to initializers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Rails.application.assets.logger = Logger.new('/dev/null') | |
| Rails::Rack::Logger.class_eval do | |
| alias_method :logger_call, :call | |
| def call(env) | |
| previous_level = Rails.logger.level | |
| #TODO: | |
| #Move paths to yaml file as it grows | |
| paths = %w(/assets/ /my_queues/ /their_queues/) | |
| use_error_logger = false | |
| paths.each do |x| | |
| use_error_logger = true if env['PATH_INFO'].include?(x) | |
| end | |
| Rails.logger.level = Logger::ERROR if use_error_logger | |
| logger_call env | |
| ensure | |
| Rails.logger.level = previous_level | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment