Module: BufferedLogger::Indentation

Included in:
BufferedLogger
Defined in:
lib/buffered_logger/indentation.rb

Constant Summary collapse

INDENT_LEVEL =
2

Instance Method Summary collapse

Instance Method Details

#indent(level = INDENT_LEVEL, &block) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/buffered_logger/indentation.rb', line 13

def indent(level = INDENT_LEVEL, &block)
  if block_given?
    padding.indent(level)
    ret_val = block.call
    padding.indent(-level)
    return ret_val
  else
    padding.indent(level)
  end
end

#initializeObject



4
5
6
7
# File 'lib/buffered_logger/indentation.rb', line 4

def initialize
  @padding = BufferedLogger::ThreadHash.new { |h,k| h[k] = BufferedLogger::Padding.new }
  super()
end

#paddingObject



9
10
11
# File 'lib/buffered_logger/indentation.rb', line 9

def padding
  @padding[Thread.current]
end