Class: Tango::Logger
- Inherits:
-
Object
- Object
- Tango::Logger
- Defined in:
- lib/tango/logger.rb
Class Method Summary collapse
Instance Method Summary collapse
- #begin_step(step_name) ⇒ Object
-
#initialize(io = STDERR) ⇒ Logger
constructor
A new instance of Logger.
- #log(message, colour = nil) ⇒ Object
- #log_raw(message) ⇒ Object
- #step_met(step_name) ⇒ Object
- #step_not_met(step_name) ⇒ Object
Constructor Details
#initialize(io = STDERR) ⇒ Logger
Returns a new instance of Logger.
23 24 25 26 |
# File 'lib/tango/logger.rb', line 23 def initialize(io = STDERR) @io = io @depth = 0 end |
Class Method Details
Instance Method Details
#begin_step(step_name) ⇒ Object
28 29 30 31 |
# File 'lib/tango/logger.rb', line 28 def begin_step(step_name) log "#{yellow(step_name)} {" @depth += 1 end |
#log(message, colour = nil) ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/tango/logger.rb', line 43 def log(, colour = nil) if colour && ::Tango::TermANSIColorStubs::ALLOWED_COLOURS.include?(colour) @io.puts send(colour,"#{indent}#{}") else @io.puts "#{indent}#{}" end end |
#log_raw(message) ⇒ Object
52 53 54 |
# File 'lib/tango/logger.rb', line 52 def log_raw() @io.write end |
#step_met(step_name) ⇒ Object
33 34 35 36 |
# File 'lib/tango/logger.rb', line 33 def step_met(step_name) @depth -= 1 log "} #{green("√ #{step_name}")}" end |
#step_not_met(step_name) ⇒ Object
38 39 40 41 |
# File 'lib/tango/logger.rb', line 38 def step_not_met(step_name) @depth -= 1 log "} #{red("✕ #{step_name}")}\n\n" end |