Class: Retag::Logger

Inherits:
Logger
  • Object
show all
Defined in:
lib/retag/logger.rb

Instance Method Summary collapse

Instance Method Details

#format_message(severity, datetime, progname, msg) ⇒ Object



28
29
30
# File 'lib/retag/logger.rb', line 28

def format_message(severity, datetime, progname, msg)
  super(severity, datetime, progname, "#{' ' * (@shift || 0)}#{msg}")
end

#shift(spaces: 2, &block) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/retag/logger.rb', line 7

def shift(spaces: 2, &block)
  if block_given?
    with_shift(spaces: spaces, &block)
  else
    @shift ||= 0
    @shift += spaces
  end
end

#unshift(spaces: 2) ⇒ Object



16
17
18
19
# File 'lib/retag/logger.rb', line 16

def unshift(spaces: 2)
  @shift ||= 0
  @shift -= spaces
end

#with_shift(spaces: 2) ⇒ Object



21
22
23
24
25
26
# File 'lib/retag/logger.rb', line 21

def with_shift(spaces: 2)
  shift(spaces: spaces)
  yield
ensure
  unshift(spaces: spaces)
end