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.
This commit is contained in:
Benjamin Neff 2017-07-30 03:43:07 +02:00
parent 1360dd4207
commit 29a7f151b6
No known key found for this signature in database
GPG key ID: 971464C3F1A90194
5 changed files with 13 additions and 6 deletions

View file

@ -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

View file

@ -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)

View file

@ -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]

View file

@ -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

View file

@ -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