Class: Wordmove::Logger

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

Constant Summary collapse

ERROR =
0
INFO =
1
VERBOSE =
2

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#levelObject

Returns the value of attribute level


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

def level
  @level
end

Instance Method Details

#error(message) ⇒ Object


27
28
29
# File 'lib/wordmove/logger.rb', line 27

def error(message)
  log ERROR, message
end

#info(message) ⇒ Object


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

def info(message)
  log INFO, message
end

#log(l, message) ⇒ Object


12
13
14
15
16
17
# File 'lib/wordmove/logger.rb', line 12

def log(l, message)
  colors = [ :red, :green, :cyan ]
  if l <= level
    puts "  " * [l-1, 0].max + message.send(colors[l])
  end
end

#verbose(message) ⇒ Object


23
24
25
# File 'lib/wordmove/logger.rb', line 23

def verbose(message)
  log VERBOSE, message
end