Module: LoggerClassMethods

Included in:
Motion::Log
Defined in:
lib/logger/log.rb

Constant Summary collapse

FLAGS =
{
  :error    => (1<<0),   # 0...0001
  :warn     => (1<<1),    # 0...0010
  :info     => (1<<2),    # 0...0100
  :verbose  => (1<<3), # 0...1000
  :debug    => (1<<3)    # 0...1000
}
LEVELS =
{
  :off      => 0,
  :error    => FLAGS[:error],
  :warn     => FLAGS[:error] | FLAGS[:warn],
  :info     => FLAGS[:error] | FLAGS[:warn] | FLAGS[:info],
  :verbose  => FLAGS[:error] | FLAGS[:warn] | FLAGS[:info] | FLAGS[:verbose],
  :debug    => FLAGS[:error] | FLAGS[:warn] | FLAGS[:info] | FLAGS[:verbose]
}

Instance Method Summary collapse

Instance Method Details

#asyncObject



31
32
33
# File 'lib/logger/log.rb', line 31

def async
  @async
end

#async=(async) ⇒ Object



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

def async=(async)
  @async = async
end

#debug(message) ⇒ Object Also known as: verbose



47
48
49
# File 'lib/logger/log.rb', line 47

def debug(message)
  __log(:verbose, message)
end

#error(message) ⇒ Object



35
36
37
# File 'lib/logger/log.rb', line 35

def error(message)
  __log(:error, message)
end

#info(message) ⇒ Object



43
44
45
# File 'lib/logger/log.rb', line 43

def info(message)
  __log(:info, message)
end

#levelObject



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

def level
  @level
end

#level=(level) ⇒ Object



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

def level=(level)
  @level = level
end

#logging?(flag) ⇒ Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/logger/log.rb', line 52

def logging?(flag)
  (LEVELS[level] & FLAGS[flag]) > 0
end

#warn(message) ⇒ Object



39
40
41
# File 'lib/logger/log.rb', line 39

def warn(message)
  __log(:warn, message)
end