Skip to content
This repository
Browse code

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
José Valim authored January 18, 2012
2  actionpack/CHANGELOG.md
Source Rendered
... ...
@@ -1,5 +1,7 @@
1 1
 ## Rails 3.2.0 (unreleased) ##
2 2
 
  3
+*   Setting config.assets.logger to false turn off Sprockets logger *Guillermo Iguaran*
  4
+
3 5
 *   Add `config.action_dispatch.default_charset` to configure default charset for ActionDispatch::Response. *Carlos Antonio da Silva*
4 6
 
5 7
 *   Deprecate setting default charset at controller level, use the new `config.action_dispatch.default_charset` instead. *Carlos Antonio da Silva*
5  actionpack/lib/sprockets/railtie.rb
@@ -21,9 +21,12 @@ class Railtie < ::Rails::Railtie
21 21
       require 'sprockets'
22 22
 
23 23
       app.assets = Sprockets::Environment.new(app.root.to_s) do |env|
24  
-        env.logger  = config.assets.logger || ::Rails.logger
25 24
         env.version = ::Rails.env + "-#{config.assets.version}"
26 25
 
  26
+        if config.assets.logger != false
  27
+          env.logger  = config.assets.logger || ::Rails.logger
  28
+        end
  29
+
27 30
         if config.assets.cache_store != false
28 31
           env.cache = ActiveSupport::Cache.lookup_store(config.assets.cache_store) || ::Rails.cache
29 32
         end
3  railties/guides/source/configuring.textile
Source Rendered
@@ -156,8 +156,7 @@ Rails 3.1, by default, is set up to use the +sprockets+ gem to manage assets wit
156 156
 
157 157
 * +config.assets.compile+ is a boolean that can be used to turn on live Sprockets compilation in production.
158 158
 
159  
-* +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+.
160  
-
  159
+* +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.
161 160
 
162 161
 h4. Configuring Generators
163 162
 
1  railties/lib/rails/application/configuration.rb
@@ -57,6 +57,7 @@ def initialize(*)
57 57
         @assets.js_compressor            = nil
58 58
         @assets.css_compressor           = nil
59 59
         @assets.initialize_on_precompile = true
  60
+        @assets.logger                   = nil
60 61
       end
61 62
 
62 63
       def compiled_asset_path

3 notes on commit f74afd9

Yury Korolev

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 Korolev

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

Guillermo Iguaran

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.