Permalink
Browse files

deprecation warning when BufferedLogger is instantiated

  • Loading branch information...
senny committed Dec 25, 2012
1 parent 95fa0e6 commit 8787c6e0e581315c8d3d33b6bb65a6640835456e
@@ -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
@@ -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 8787c6e

Please sign in to comment.