Class: Tipsy::Utils::Logger

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

Constant Summary collapse

COLORS =
{ :clear => 0, :red => 31, :green => 32, :yellow => 33 }

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#stdoutObject (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

#errorObject



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


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