diff options
Diffstat (limited to 'activesupport/lib/active_support/logger.rb')
-rw-r--r-- | activesupport/lib/active_support/logger.rb | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/activesupport/lib/active_support/logger.rb b/activesupport/lib/active_support/logger.rb index de48e717b6..8152a182b4 100644 --- a/activesupport/lib/active_support/logger.rb +++ b/activesupport/lib/active_support/logger.rb @@ -1,6 +1,8 @@ -require 'active_support/logger_silence' -require 'active_support/logger_thread_safe_level' -require 'logger' +# frozen_string_literal: true + +require "active_support/logger_silence" +require "active_support/logger_thread_safe_level" +require "logger" module ActiveSupport class Logger < ::Logger @@ -55,6 +57,24 @@ module ActiveSupport logger.local_level = level if logger.respond_to?(:local_level=) super(level) if respond_to?(:local_level=) end + + define_method(:silence) do |level = Logger::ERROR, &block| + if logger.respond_to?(:silence) + logger.silence(level) do + if defined?(super) + super(level, &block) + else + block.call(self) + end + end + else + if defined?(super) + super(level, &block) + else + block.call(self) + end + end + end end end |