6

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

Rubytastic
  • 15,001
  • 18
  • 87
  • 175
  • This one is already answered at http://stackoverflow.com/questions/6312448/how-to-disable-logging-of-asset-pipeline-sprockets-messages-in-rails-3-1 – Nilesh Jan 28 '12 at 13:57

3 Answers3

3

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
Mikhail Nikalyukin
  • 11,867
  • 1
  • 46
  • 70
  • Not home right now behing the dev machine, but definitly try this out!I let you know if this works thx! Where did you find this information? – Rubytastic Jan 28 '12 at 14:36
  • This is working for me in two projects, find this info there https://github.com/rails/rails/issues/2639 . – Mikhail Nikalyukin Jan 28 '12 at 14:40
  • Very nice thanks, I flag it correct then since its the same as on github page you submitted and should work correctly, great finally remove those assets and the scrolling when debugging ! thx (y) – Rubytastic Jan 28 '12 at 14:48
1

In case anybody else stumbles upon this as I did here is a simpler solution. https://github.com/evrone/quiet_assets

Gowiem
  • 1,297
  • 17
  • 19
1

Add this line to your development.rb file.

config.assets.debug = false
Santhosh
  • 28,097
  • 9
  • 82
  • 87