Class: Tango::Logger

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io = STDERR) ⇒ Logger

Returns a new instance of Logger.



9
10
11
12
# File 'lib/tango/logger.rb', line 9

def initialize(io = STDERR)
  @io = io
  @depth = 0
end

Class Method Details

.instanceObject



5
6
7
# File 'lib/tango/logger.rb', line 5

def self.instance
  @logger ||= Logger.new
end

Instance Method Details

#enter(step_name) ⇒ Object



14
15
16
17
# File 'lib/tango/logger.rb', line 14

def enter(step_name)
  log "#{step_name} {"
  @depth += 1
end

#leave(step_name) ⇒ Object



19
20
21
22
# File 'lib/tango/logger.rb', line 19

def leave(step_name)
  @depth -= 1
  log "} √ #{step_name}"
end

#log(message) ⇒ Object



24
25
26
# File 'lib/tango/logger.rb', line 24

def log(message)
  @io.puts "#{indent}#{message}"
end

#log_raw(message) ⇒ Object



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

def log_raw(message)
  @io.write message
end