Class: SSHKit::DeprecationLogger
- Inherits:
-
Object
- Object
- SSHKit::DeprecationLogger
- Defined in:
- lib/sshkit/deprecation_logger.rb
Instance Method Summary collapse
-
#initialize(out) ⇒ DeprecationLogger
constructor
A new instance of DeprecationLogger.
- #log(message) ⇒ Object
Constructor Details
#initialize(out) ⇒ DeprecationLogger
Returns a new instance of DeprecationLogger.
5 6 7 8 |
# File 'lib/sshkit/deprecation_logger.rb', line 5 def initialize(out) @out = out @previous_warnings = Set.new end |
Instance Method Details
#log(message) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/sshkit/deprecation_logger.rb', line 10 def log() return if @out.nil? warning_msg = "[Deprecated] #{}\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 |