Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #4512 from guilleiguaran/silent-sprockets-logger

Silent Sprockets logger when config.assets.logger is set to false
  • Loading branch information...
commit 5b9a506ef6b72c93901e94a0f738c1991f8d5852 2 parents 5065d17 + 226783d
@josevalim josevalim authored
View
5 actionpack/lib/sprockets/railtie.rb
@@ -21,9 +21,12 @@ class Railtie < ::Rails::Railtie
require 'sprockets'
app.assets = Sprockets::Environment.new(app.root.to_s) do |env|
- env.logger = config.assets.logger || ::Rails.logger
env.version = ::Rails.env + "-#{config.assets.version}"
+ if config.assets.logger != false
+ env.logger = config.assets.logger || ::Rails.logger
+ end
+
if config.assets.cache_store != false
env.cache = ActiveSupport::Cache.lookup_store(config.assets.cache_store) || ::Rails.cache
end
View
1  railties/lib/rails/application/configuration.rb
@@ -57,6 +57,7 @@ def initialize(*)
@assets.js_compressor = nil
@assets.css_compressor = nil
@assets.initialize_on_precompile = true
+ @assets.logger = nil
end
def compiled_asset_path

2 comments on commit 5b9a506

@j-manu

Shouldn't another config variable be used to silence the sprocket logs ? The current naming & behaviour is a bit confusing.

config.assets.logger = nil  # currently logs using Rails logger
config.assets.logger = false # currently silences log output

These two options should ideally behave the same? Also I expect config.assets.logger to be used to define a Logger and not influence
whether the logging will happen or not.

@j-manu

env.logger = config.assets.logger || ::Rails.logger is sufficient to disable sprockets logging as the logger can be set to Logger.new '/dev/null' or a logger with higher level. This will also make the config.assets.logger setting behave exactly like config.logger setting i.e nil or false will use the default logger.

Please sign in to comment.
Something went wrong with that request. Please try again.