Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #4518 from guilleiguaran/silent-sprockets-logger-3…

…-2-stable

Silent Sprockets logger when config.assets.logger is set to false (3-2-stable)
  • Loading branch information...
commit f74afd973dd41dd081978025b96332a5b5cc39b0 2 parents 2f52bd3 + ae7037e
@josevalim josevalim authored
View
2  actionpack/CHANGELOG.md
@@ -1,5 +1,7 @@
## Rails 3.2.0 (unreleased) ##
+* Setting config.assets.logger to false turn off Sprockets logger *Guillermo Iguaran*
+
* Add `config.action_dispatch.default_charset` to configure default charset for ActionDispatch::Response. *Carlos Antonio da Silva*
* Deprecate setting default charset at controller level, use the new `config.action_dispatch.default_charset` instead. *Carlos Antonio da Silva*
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
3  railties/guides/source/configuring.textile
@@ -156,8 +156,7 @@ Rails 3.1, by default, is set up to use the +sprockets+ gem to manage assets wit
* +config.assets.compile+ is a boolean that can be used to turn on live Sprockets compilation in production.
-* +config.assets.logger+ accepts a logger conforming to the interface of Log4r or the default Ruby +Logger+ class. Defaults to the same configured at +config.logger+.
-
+* +config.assets.logger+ accepts a logger conforming to the interface of Log4r or the default Ruby +Logger+ class. Defaults to the same configured at +config.logger+. Setting +config.assets.logger+ to false will turn off served assets logging.
h4. Configuring Generators
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

3 comments on commit f74afd9

@yury

Hmm, just tried with

gem 'rails', git: 'https://github.com/rails/rails.git', branch: '3-2-stable'

tried false, and Logger.new('/dev/null') but still get assets logs

config.assets.logger = false #Logger.new('/dev/null')
@yury

::Rails::Rack::Logger is making noise with Rails.logger.info

@guilleiguaran

This clean Sprockets logger but we won't modify Rails::Rack::Logger, see #3795 (comment)

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