Class: Tipsy::Utils::Logger
- Inherits:
-
Object
- Object
- Tipsy::Utils::Logger
- Defined in:
- lib/tipsy/utils/logger.rb
Constant Summary collapse
- COLORS =
{ :clear => 0, :red => 31, :green => 32, :yellow => 33 }
Instance Attribute Summary collapse
-
#stdout ⇒ Object
readonly
Returns the value of attribute stdout.
Instance Method Summary collapse
- #action(name, action) ⇒ Object
- #error ⇒ Object
- #info(msg, color = :clear) ⇒ Object
-
#initialize(o) ⇒ Logger
constructor
A new instance of Logger.
- #print(msg) ⇒ Object
- #warn(msg) ⇒ Object
Constructor Details
#initialize(o) ⇒ Logger
Returns a new instance of Logger.
7 8 9 |
# File 'lib/tipsy/utils/logger.rb', line 7 def initialize(o) @stdout = o end |
Instance Attribute Details
#stdout ⇒ Object (readonly)
Returns the value of attribute stdout.
5 6 7 |
# File 'lib/tipsy/utils/logger.rb', line 5 def stdout @stdout end |
Instance Method Details
#action(name, action) ⇒ Object
15 16 17 |
# File 'lib/tipsy/utils/logger.rb', line 15 def action(name, action) print colorize(:green, (name.rjust(12, ' ') << " "), :clear, action) end |
#error ⇒ Object
27 28 29 |
# File 'lib/tipsy/utils/logger.rb', line 27 def error print colorize(:red, "Error: ", :clear, msg) end |
#info(msg, color = :clear) ⇒ Object
19 20 21 |
# File 'lib/tipsy/utils/logger.rb', line 19 def info(msg, color = :clear) print colorize(color, msg) unless Tipsy.env.eql?("test") end |
#print(msg) ⇒ Object
11 12 13 |
# File 'lib/tipsy/utils/logger.rb', line 11 def print(msg) puts msg end |
#warn(msg) ⇒ Object
23 24 25 |
# File 'lib/tipsy/utils/logger.rb', line 23 def warn(msg) print colorize(:yellow, "Warning: ", :clear, msg) end |