Sha256: 5ca4df9dd7241207500be0cc9b5d88a8feb291fba522b25f6066b2c033e7a183

Contents?: true

Size: 476 Bytes

Versions: 6

Compression:

Stored size: 476 Bytes

Contents

require 'core_ext/concern'

module CoreExt::LoggerSilence
  extend CoreExt::Concern

  included do
    cattr_accessor :silencer
    self.silencer = true
  end

  # Silences the logger for the duration of the block.
  def silence(temporary_level = Logger::ERROR)
    if silencer
      begin
        old_logger_level, self.level = level, temporary_level
        yield self
      ensure
        self.level = old_logger_level
      end
    else
      yield self
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
core_ext-0.0.6 lib/core_ext/logger_silence.rb
core_ext-0.0.5 lib/core_ext/logger_silence.rb
core_ext-0.0.4 lib/core_ext/logger_silence.rb
core_ext-0.0.3 lib/core_ext/logger_silence.rb
core_ext-0.0.2 lib/core_ext/logger_silence.rb
core_ext-0.0.1 lib/core_ext/logger_silence.rb