Permalink
Browse files

Disable asset logging in development

  • Loading branch information...
1 parent 3b4c769 commit a4febaa03ff62150e9d6c9fb5a5a02a56df023f1 @foca committed Jul 24, 2012
Showing with 24 additions and 0 deletions.
  1. +5 −0 config/environments/development.rb
  2. +19 −0 lib/disable_assets_logger.rb
@@ -1,3 +1,5 @@
+require "disable_assets_logger"
+
BlankSlate::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
@@ -34,4 +36,7 @@
# Expands the lines which load the assets
config.assets.debug = true
+
+ # Disable verbose logging of asset-pipeline requests
+ config.middleware.insert_before Rails::Rack::Logger, DisableAssetsLogger
end
@@ -0,0 +1,19 @@
+# Disable the _verbose_ log output from the asset pipeline in development.
+# Thanks to [macournoyer][source].
+#
+# [source]: https://github.com/rails/rails/issues/2639#issuecomment-6591735
+#
+class DisableAssetsLogger
+ def initialize(app)
+ @app = app
+ Rails.application.assets.logger = Logger.new('/dev/null')
+ end
+
+ def call(env)
+ previous_level = Rails.logger.level
+ Rails.logger.level = Logger::ERROR if env['PATH_INFO'].index("/assets/") == 0
+ @app.call(env)
+ ensure
+ Rails.logger.level = previous_level
+ end
+end

0 comments on commit a4febaa

Please sign in to comment.