Class: Filbunke::FilbunkeLogger

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

Instance Method Summary collapse

Constructor Details

#initialize(log_file_name, local, level) ⇒ FilbunkeLogger

Returns a new instance of FilbunkeLogger.



5
6
7
8
9
10
11
12
13
14
# File 'lib/filbunke/logger.rb', line 5

def initialize(log_file_name, local, level)
  @local = local
  @log = if @local or log_file_name.nil?
    Logger.new(STDOUT) 
  else 
    Logger.new(log_file_name)
  end

  @log.level = parse_level(level)
end

Instance Method Details

#debug(msg) ⇒ Object



36
37
38
# File 'lib/filbunke/logger.rb', line 36

def debug(msg)
  @log.debug msg
end

#error(msg) ⇒ Object



28
29
30
# File 'lib/filbunke/logger.rb', line 28

def error(msg)
  @log.error msg
end

#fatal(msg) ⇒ Object



40
41
42
# File 'lib/filbunke/logger.rb', line 40

def fatal(msg)
  @log.error msg
end

#info(msg) ⇒ Object



24
25
26
# File 'lib/filbunke/logger.rb', line 24

def info(msg)
  @log.info msg
end

#log(msg) ⇒ Object



20
21
22
# File 'lib/filbunke/logger.rb', line 20

def log(msg)
  @log.info msg
end

#parse_level(constantOrString) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/filbunke/logger.rb', line 44

def parse_level(constantOrString)
  case constantOrString
    when 'debug' then Logger::DEBUG
    when 'info' then Logger::INFO
    when 'warn' then Logger::WARN
    when 'error' then Logger::ERROR
    when 'fatal' then Logger::ERROR
    when 'unknown' then Logger::UNKNOWN
    when nil then Logger::INFO
    else 
      constantOrString
  end
end

#puts(msg) ⇒ Object



16
17
18
# File 'lib/filbunke/logger.rb', line 16

def puts(msg)
  info(msg)
end

#warn(msg) ⇒ Object



32
33
34
# File 'lib/filbunke/logger.rb', line 32

def warn(msg)
  @log.warn msg
end