2017-07-09 08:06:36 -04:00
|
|
|
# frozen_string_literal: true
|
2017-07-10 09:39:13 -04:00
|
|
|
|
2017-10-21 09:11:29 -04:00
|
|
|
require "active_support/concern"
|
|
|
|
require "active_support/core_ext/module/attribute_accessors"
|
2018-10-02 17:02:27 -04:00
|
|
|
require "active_support/logger_thread_safe_level"
|
2012-12-21 13:35:10 -05:00
|
|
|
|
2018-10-01 18:00:18 -04:00
|
|
|
module ActiveSupport
|
|
|
|
module LoggerSilence
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
included do
|
|
|
|
cattr_accessor :silencer, default: true
|
2018-10-02 17:02:27 -04:00
|
|
|
include ActiveSupport::LoggerThreadSafeLevel
|
2018-10-01 18:00:18 -04:00
|
|
|
end
|
2012-12-21 13:35:10 -05:00
|
|
|
|
2018-10-01 18:00:18 -04:00
|
|
|
# Silences the logger for the duration of the block.
|
2019-09-24 13:47:34 -04:00
|
|
|
def silence(severity = Logger::ERROR)
|
|
|
|
silencer ? log_at(severity) { yield self } : yield(self)
|
2012-12-21 13:35:10 -05:00
|
|
|
end
|
|
|
|
end
|
2016-02-11 15:00:51 -05:00
|
|
|
end
|