Sha256: 9e341258e54b3869abef39fff693ad4e9b2e0f792ea9ca8ee42172ad6eabfb39

Contents?: true

Size: 1.02 KB

Versions: 23

Compression:

Stored size: 1.02 KB

Contents

require 'logger'
require File.dirname(__FILE__) + '/core_ext/class/attribute_accessors'

class Logger #:nodoc:
  cattr_accessor :silencer
  self.silencer = true

  # 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

  private
    alias old_format_message format_message

    # Ruby 1.8.3 transposed the msg and progname arguments to format_message.
    # We can't test RUBY_VERSION because some distributions don't keep Ruby
    # and its standard library in sync, leading to installations of Ruby 1.8.2
    # with Logger from 1.8.3 and vice versa.
    if method_defined?(:formatter=)
      def format_message(severity, timestamp, progname, msg)
        "#{msg}\n"
      end
    else
      def format_message(severity, timestamp, msg, progname)
        "#{msg}\n"
      end
    end
end

Version data entries

23 entries across 23 versions & 5 rubygems

Version Path
jstorimer-deep-test-2.0.0 sample_rails_project/vendor/rails/activesupport/lib/active_support/clean_logger.rb
jstorimer-deep-test-1.4.0 sample_rails_project/vendor/rails/activesupport/lib/active_support/clean_logger.rb
jstorimer-deep-test-1.3.0 sample_rails_project/vendor/rails/activesupport/lib/active_support/clean_logger.rb
jstorimer-deep-test-1.2.0 sample_rails_project/vendor/rails/activesupport/lib/active_support/clean_logger.rb
jstorimer-deep-test-1.1.0 sample_rails_project/vendor/rails/activesupport/lib/active_support/clean_logger.rb
jstorimer-deep-test-1.0.0 sample_rails_project/vendor/rails/activesupport/lib/active_support/clean_logger.rb
jstorimer-deep-test-0.2.0 sample_rails_project/vendor/rails/activesupport/lib/active_support/clean_logger.rb
jstorimer-deep-test-0.1.0 sample_rails_project/vendor/rails/activesupport/lib/active_support/clean_logger.rb
activesupport-1.4.3 lib/active_support/clean_logger.rb
activesupport-1.3.0 lib/active_support/clean_logger.rb
activesupport-1.3.1 lib/active_support/clean_logger.rb
activesupport-1.4.0 lib/active_support/clean_logger.rb
activesupport-1.4.2 lib/active_support/clean_logger.rb
activesupport-1.4.4 lib/active_support/clean_logger.rb
activesupport-1.4.1 lib/active_support/clean_logger.rb
monetra-ruby-0.0.6 lib/monetra/active_support/clean_logger.rb
radiant-0.6.1 vendor/rails/activesupport/lib/active_support/clean_logger.rb
radiant-0.6.0 vendor/rails/activesupport/lib/active_support/clean_logger.rb
radiant-0.6.3 vendor/rails/activesupport/lib/active_support/clean_logger.rb
radiant-0.6.2 vendor/rails/activesupport/lib/active_support/clean_logger.rb