Module: IDRAC::Debuggable

Included in:
Client, Session, Utility
Defined in:
lib/idrac.rb

Overview

Provides debugging functionality to IDRAC classes

Instance Method Summary collapse

Instance Method Details

#debug(message, level = 1, color = :light_cyan) ⇒ Object

Debug output helper - only outputs if verbosity level is high enough



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/idrac.rb', line 19

def debug(message, level = 1, color = :light_cyan)
  return unless respond_to?(:verbosity) && verbosity >= level
  color_method = color.is_a?(Symbol) && String.method_defined?(color) ? color : :to_s
  puts message.send(color_method)
  
  # For highest verbosity, also print stack trace
  if respond_to?(:verbosity) && verbosity >= 3 && caller.length > 1
    puts "  Called from:".light_yellow
    caller[1..3].each do |call|
      puts "    #{call}".light_yellow
    end
  end
end