Skip to content

Instantly share code, notes, and snippets.

@jadon1979
Created May 1, 2013 15:31
Show Gist options
  • Select an option

  • Save jadon1979/5495996 to your computer and use it in GitHub Desktop.

Select an option

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
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