class Knapsack::Logger

Constants

DEBUG
INFO
UnknownLogLevel
WARN

Attributes

level[RW]

Public Instance Methods

debug(text=nil) click to toggle source
# File lib/knapsack/logger.rb, line 23
def debug(text=nil)
  return if level != DEBUG
  puts text
end
info(text=nil) click to toggle source
# File lib/knapsack/logger.rb, line 28
def info(text=nil)
  return if level > INFO
  puts text
end
log(level, text=nil) click to toggle source
# File lib/knapsack/logger.rb, line 11
def log(level, text=nil)
  level_method =
    case level
    when DEBUG then :debug
    when INFO then :info
    when WARN then :warn
    else raise UnknownLogLevel
    end

  public_send(level_method, text)
end
warn(text=nil) click to toggle source
# File lib/knapsack/logger.rb, line 33
def warn(text=nil)
  return if level > WARN
  puts text
end