Module: Loom::Logger::LoggerDebugLevels

Defined in:
lib/loom/logger.rb

Constant Summary collapse

NUM_DEBUG_LEVELS =
6

Instance Method Summary collapse

Instance Method Details

#debug_levelObject

Adds methods debug1, debug2, … debug6 for more detailed debug levels. Set a negative index logger.level to enable lower levels, e.g. logger.level = -6 for debug6 messages.



85
86
87
88
89
90
91
92
93
94
# File 'lib/loom/logger.rb', line 85

(1..NUM_DEBUG_LEVELS).to_a.each do |debug_level|
  debug_method_name = "debug#{debug_level}"

  define_method debug_method_name do |*args, &block|
    severity = debug_level * -1
    return if severity < self.level

    debug_at_level severity, *args, &block
  end
end

#format_severity(severity) ⇒ Object



96
97
98
99
100
101
102
# File 'lib/loom/logger.rb', line 96

def format_severity(severity)
  if severity < ::Logger::DEBUG
    return "D" + severity.abs.to_s
  else
    super(severity)[0]
  end
end