Fix Issue #2639: "Served asset log messages are pretty annoying!" by adding config variable #3795

Closed
wants to merge 1 commit into
from
@@ -21,8 +21,9 @@ class Railtie < ::Rails::Railtie
require 'sprockets'
+ # Don't display Sprockets log messages if config.assets.logger is false in envrionment
app.assets = Sprockets::Environment.new(app.root.to_s) do |env|
- env.logger = ::Rails.logger
+ env.logger = ::Rails.logger unless config.assets.logger == false
env.version = ::Rails.env + "-#{config.assets.version}"
if config.assets.cache_store != false
@@ -21,8 +21,12 @@ def before_dispatch(env)
request = ActionDispatch::Request.new(env)
path = request.filtered_path
- info "\n\nStarted #{request.request_method} \"#{path}\" " \
- "for #{request.ip} at #{Time.now.to_default_s}"
+ # If config.assets.logger is set to false, only log non-assets related requests
+ if ((Rails.application.config.assets.logger != false) ||
@drogus
drogus Dec 10, 2011 Ruby on Rails member

You should not use Rails.application here, please see how it's done in case of other similar options: https://github.com/ciscoriordan/rails/blob/4928434455c9a89197fda106534f57f6b319184c/railties/lib/rails/application.rb#L121

/cc @josevalim

+ (env['PATH_INFO'].index("/assets/") != 0))
+ info "\n\nStarted #{request.request_method} \"#{path}\"" \
+ " for #{request.ip} at #{Time.now.to_default_s}"
+ end
end
def after_dispatch(env)