Class: SSHKit::DeprecationLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/sshkit/deprecation_logger.rb

Instance Method Summary collapse

Constructor Details

#initialize(out) ⇒ DeprecationLogger


3
4
5
6
# File 'lib/sshkit/deprecation_logger.rb', line 3

def initialize(out)
  @out = out
  @previous_warnings = Set.new
end

Instance Method Details

#log(message) ⇒ Object


8
9
10
11
12
13
14
15
# File 'lib/sshkit/deprecation_logger.rb', line 8

def log(message)
  return if @out.nil?
  warning_msg = "[Deprecated] #{message}\n"
  caller_line = caller.find { |line| !line.include?('lib/sshkit') }
  warning_msg << "    (Called from #{caller_line})\n" unless caller_line.nil?
  @out << warning_msg unless @previous_warnings.include?(warning_msg)
  @previous_warnings << warning_msg
end