Skip to content

Commit

Permalink
deprecation warning when BufferedLogger is instantiated
Browse files Browse the repository at this point in the history
  • Loading branch information
senny committed Dec 25, 2012
1 parent 95fa0e6 commit 8787c6e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
12 changes: 11 additions & 1 deletion activesupport/lib/active_support/buffered_logger.rb
Expand Up @@ -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
8 changes: 8 additions & 0 deletions activesupport/test/deprecation/buffered_logger_test.rb
Expand Up @@ -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.