Permalink
Browse files

Merge pull request #8608 from senny/8576_cant_inherit_from_deprecated…

…_buffered_logger

deprecation warning when BufferedLogger is instantiated
  • Loading branch information...
2 parents ea6cddd + 8787c6e commit 227d4e9bdd445f936ff2a2752b4e42d401b6e3cb @rafaelfranca rafaelfranca committed Dec 25, 2012
View
12 activesupport/lib/active_support/buffered_logger.rb
@@ -3,9 +3,19 @@
module ActiveSupport
class BufferedLogger < Logger
+
+ def initialize(*args)
+ self.class._deprecation_warning
+ super
+ end
+
def self.inherited(*)
- ::ActiveSupport::Deprecation.warn 'ActiveSupport::BufferedLogger is deprecated! Use ActiveSupport::Logger instead.'
+ _deprecation_warning
super
end
+
+ def self._deprecation_warning
+ ::ActiveSupport::Deprecation.warn 'ActiveSupport::BufferedLogger is deprecated! Use ActiveSupport::Logger instead.'
+ end
end
end
View
8 activesupport/test/deprecation/buffered_logger_test.rb
@@ -11,4 +11,12 @@ def test_can_be_subclassed
Class.new(ActiveSupport::BufferedLogger)
end
+ def test_issues_deprecation_when_instantiated
+ warn = 'ActiveSupport::BufferedLogger is deprecated! Use ActiveSupport::Logger instead.'
+
+ ActiveSupport::Deprecation.expects(:warn).with(warn).once
+
+ ActiveSupport::BufferedLogger.new(STDOUT)
+ end
+
end

0 comments on commit 227d4e9

Please sign in to comment.