aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/logger_silence.rb
diff options
context:
space:
mode:
authorEdouard CHIN <edouard.chin@shopify.com>2018-10-01 18:00:18 -0400
committerEdouard CHIN <edouard.chin@shopify.com>2018-10-02 12:59:04 -0400
commit783f86822b49aa39d122f9c86939a17dac869cad (patch)
tree2278ea2002e443b53103a10c3baeea50eacab580 /activesupport/lib/active_support/logger_silence.rb
parentcf608ee34dd833b0357ef4eefa692db33242d2aa (diff)
downloadrails-783f86822b49aa39d122f9c86939a17dac869cad.tar.gz
rails-783f86822b49aa39d122f9c86939a17dac869cad.tar.bz2
rails-783f86822b49aa39d122f9c86939a17dac869cad.zip
Deprecate the `LoggerSilence` constant:
- I found this weird that the LoggerSilence wasn't using the `ActiveSupport` namespace (AFAIK all other classes have it). This PR deprecate the use of `LoggerSilence` for `ActiveSupport::LoggerSilence` instead.
Diffstat (limited to 'activesupport/lib/active_support/logger_silence.rb')
-rw-r--r--activesupport/lib/active_support/logger_silence.rb37
1 files changed, 26 insertions, 11 deletions
diff --git a/activesupport/lib/active_support/logger_silence.rb b/activesupport/lib/active_support/logger_silence.rb
index 4344ca0429..2f62cc13b9 100644
--- a/activesupport/lib/active_support/logger_silence.rb
+++ b/activesupport/lib/active_support/logger_silence.rb
@@ -7,22 +7,37 @@ module LoggerSilence
extend ActiveSupport::Concern
included do
- cattr_accessor :silencer, default: true
+ ActiveSupport::Deprecation.warn(
+ "Including LoggerSilence is deprecated and will be removed in Rails 6.1. " \
+ "Please use `ActiveSupport::LoggerSilence` instead"
+ )
+
+ include ActiveSupport::LoggerSilence
end
+end
+
+module ActiveSupport
+ module LoggerSilence
+ extend ActiveSupport::Concern
+
+ included do
+ cattr_accessor :silencer, default: true
+ end
- # Silences the logger for the duration of the block.
- def silence(temporary_level = Logger::ERROR)
- if silencer
- begin
- old_local_level = local_level
- self.local_level = temporary_level
+ # Silences the logger for the duration of the block.
+ def silence(temporary_level = Logger::ERROR)
+ if silencer
+ begin
+ old_local_level = local_level
+ self.local_level = temporary_level
+ yield self
+ ensure
+ self.local_level = old_local_level
+ end
+ else
yield self
- ensure
- self.local_level = old_local_level
end
- else
- yield self
end
end
end