module Itamae::Logger::Helper
Public Instance Methods
color(code, &block)
click to toggle source
# File lib/itamae/logger.rb, line 39 def color(code, &block) if self.formatter.respond_to?(:color) self.formatter.color(code, &block) else block.call end end
indent()
click to toggle source
# File lib/itamae/logger.rb, line 22 def indent self.indent_depth += 1 end
indent_depth()
click to toggle source
# File lib/itamae/logger.rb, line 31 def indent_depth @indent_depth ||= 0 end
indent_depth=(val)
click to toggle source
# File lib/itamae/logger.rb, line 35 def indent_depth=(val) @indent_depth = val end
outdent()
click to toggle source
# File lib/itamae/logger.rb, line 26 def outdent self.indent_depth -= 1 self.indent_depth = 0 if self.indent_depth < 0 end
with_indent() { || ... }
click to toggle source
# File lib/itamae/logger.rb, line 7 def with_indent indent yield ensure outdent end
with_indent_if(condition, &block)
click to toggle source
# File lib/itamae/logger.rb, line 14 def with_indent_if(condition, &block) if condition with_indent(&block) else block.call end end
Private Instance Methods
indent_msg(msg)
click to toggle source
# File lib/itamae/logger.rb, line 57 def indent_msg(msg) spaces = " " * indent_depth case msg when ::String "#{spaces}#{msg}" when ::Exception "#{spaces}#{msg.message} (#{msg.class})\n" << (msg.backtrace || []).map {|f| "#{spaces}#{f}"}.join("\n") else "#{spaces}#{msg.inspect}" end end