Skip to content
This repository
Browse code

Merge pull request #8608 from senny/8576_cant_inherit_from_deprecated…

…_buffered_logger

deprecation warning when BufferedLogger is instantiated
  • Loading branch information...
commit 227d4e9bdd445f936ff2a2752b4e42d401b6e3cb 2 parents ea6cddd + 8787c6e
Rafael Mendonça França rafaelfranca authored
12 activesupport/lib/active_support/buffered_logger.rb
@@ -3,9 +3,19 @@
3 3
4 4 module ActiveSupport
5 5 class BufferedLogger < Logger
  6 +
  7 + def initialize(*args)
  8 + self.class._deprecation_warning
  9 + super
  10 + end
  11 +
6 12 def self.inherited(*)
7   - ::ActiveSupport::Deprecation.warn 'ActiveSupport::BufferedLogger is deprecated! Use ActiveSupport::Logger instead.'
  13 + _deprecation_warning
8 14 super
9 15 end
  16 +
  17 + def self._deprecation_warning
  18 + ::ActiveSupport::Deprecation.warn 'ActiveSupport::BufferedLogger is deprecated! Use ActiveSupport::Logger instead.'
  19 + end
10 20 end
11 21 end
8 activesupport/test/deprecation/buffered_logger_test.rb
@@ -11,4 +11,12 @@ def test_can_be_subclassed
11 11 Class.new(ActiveSupport::BufferedLogger)
12 12 end
13 13
  14 + def test_issues_deprecation_when_instantiated
  15 + warn = 'ActiveSupport::BufferedLogger is deprecated! Use ActiveSupport::Logger instead.'
  16 +
  17 + ActiveSupport::Deprecation.expects(:warn).with(warn).once
  18 +
  19 + ActiveSupport::BufferedLogger.new(STDOUT)
  20 + end
  21 +
14 22 end

0 comments on commit 227d4e9

Please sign in to comment.
Something went wrong with that request. Please try again.