From 29a7f151b6303bdd9bb6a47130d1f40dc41a9b45 Mon Sep 17 00:00:00 2001 From: Benjamin Neff Date: Sun, 30 Jul 2017 03:43:07 +0200 Subject: [PATCH] Use config.assets.quiet instead of quiet_assets gem The quiet_assets gem doesn't support rails 5, but sprockets 3 now has a config.assets.quiet option, which deprecates the quiet_assets gem. But the logging gem has a no-op silence method, that's why the quiet option doesn't work out-of-the-box. I added a little hack to use the silence method from ActiveSupport, which is also used from the original rails logger. --- Gemfile | 3 --- Gemfile.lock | 3 --- config/environments/development.rb | 3 +++ config/environments/test.rb | 3 +++ config/logging.rb | 7 +++++++ 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index 9e0f197a5..c19e6f890 100644 --- a/Gemfile +++ b/Gemfile @@ -312,7 +312,4 @@ group :development, :test do gem "jasmine-jquery-rails", "2.0.3" gem "rails-assets-jasmine-ajax", "3.3.1", source: "https://rails-assets.org" gem "sinon-rails", "1.15.0" - - # silence assets - gem "quiet_assets", "1.1.0" end diff --git a/Gemfile.lock b/Gemfile.lock index f0adbbfb3..ddea815ec 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -463,8 +463,6 @@ GEM byebug (~> 9.0) pry (~> 0.10) public_suffix (2.0.5) - quiet_assets (1.1.0) - railties (>= 3.1, < 5.0) rack (1.6.8) rack-cors (1.0.1) rack-google-analytics (1.2.0) @@ -826,7 +824,6 @@ DEPENDENCIES pronto-scss (= 0.9.1) pry pry-byebug - quiet_assets (= 1.1.0) rack-cors (= 1.0.1) rack-google-analytics (= 1.2.0) rack-piwik (= 0.3.0) diff --git a/config/environments/development.rb b/config/environments/development.rb index 2d00a9b03..c32bb8287 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -32,6 +32,9 @@ Diaspora::Application.configure do # Expands the lines which load the assets config.assets.debug = true + # No assets request logging + config.assets.quiet = true + # Set the logging destination(s) config.log_to = %w[stdout file] diff --git a/config/environments/test.rb b/config/environments/test.rb index ad12d1620..c9fd1846d 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -16,6 +16,9 @@ Diaspora::Application.configure do config.serve_static_files = true config.static_cache_control = "public, max-age=3600" + # No assets request logging + config.assets.quiet = true + # Show full error reports and disable caching config.consider_all_requests_local = true config.action_controller.perform_caching = false diff --git a/config/logging.rb b/config/logging.rb index 57cf39b0a..2c674562d 100644 --- a/config/logging.rb +++ b/config/logging.rb @@ -103,3 +103,10 @@ Logging::Rails.configure do |config| end end end + +# Include LoggerSilence from ActiveSupport. This is needed to silent assets +# requests with `config.assets.quiet`, because the default silence method of +# the logging gem is no-op. See: https://github.com/TwP/logging/issues/11 +Logging::Logger.send :alias_method, :local_level, :level +Logging::Logger.send :alias_method, :local_level=, :level= +Logging::Logger.send :include, LoggerSilence