Is it possible to remove the loading of assets ( images for example ) from the logs? I would like to have just the view rendering in my log + with the activerecord stuff and no other things that distract.
Can you setup the logger to remove certain elements from the log such as asset loading? thx
You can add initializer quite_assets.rb with:
def is_windows?
RUBY_PLATFORM['mswin32'] || RUBY_PLATFORM['mingw'] || RUBY_PLATFORM['cygwin']
end
destination = is_windows?? 'NUL' : '/dev/null'
Rails.application.assets.logger = Logger.new(destination)
Rails::Rack::Logger.class_eval do
def call_with_quiet_assets(env)
previous_level = Rails.logger.level
Rails.logger.level = Logger::ERROR if env['PATH_INFO'].index("/assets/") == 0
call_without_quiet_assets(env).tap do
Rails.logger.level = previous_level
end
end
alias_method_chain :call, :quiet_assets
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With