Class: Outlog::BaseLogger

Inherits:
Object
  • Object
show all
Defined in:
lib/outlog/base_logger.rb

Direct Known Subclasses

ConsoleLogger, JsonLogger, NullLogger

Instance Method Summary collapse

Instance Method Details

#debug(message, hash = {}) ⇒ Object



26
27
28
# File 'lib/outlog/base_logger.rb', line 26

def debug message, hash={}
  add ::Logger::DEBUG, message, hash
end

#error(message, hash = {}) ⇒ Object



38
39
40
# File 'lib/outlog/base_logger.rb', line 38

def error message, hash={}
  add ::Logger::ERROR, message, hash
end

#fatal(message, hash = {}) ⇒ Object



42
43
44
# File 'lib/outlog/base_logger.rb', line 42

def fatal message, hash={}
  add ::Logger::FATAL, message, hash
end

#info(message, hash = {}) ⇒ Object



30
31
32
# File 'lib/outlog/base_logger.rb', line 30

def info message, hash={}
  add ::Logger::INFO, message, hash
end

#levelObject



3
4
5
6
7
# File 'lib/outlog/base_logger.rb', line 3

def level
  return @level if defined? @level
  self.level = ENV["LOG_LEVEL"] || "info"
  @level
end

#level=(new_level) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/outlog/base_logger.rb', line 17

def level= new_level
  if new_level.is_a? Integer
    @level = new_level
  else
    lookup = new_level.to_s.upcase
    @level = ::Logger::SEV_LABEL.index lookup
  end
end

#level_name(lookup = level) ⇒ Object



9
10
11
# File 'lib/outlog/base_logger.rb', line 9

def level_name lookup=level
  ::Logger::SEV_LABEL[lookup]
end

#level_symbolObject



13
14
15
# File 'lib/outlog/base_logger.rb', line 13

def level_symbol
  level_name.downcase.to_sym
end

#warn(message, hash = {}) ⇒ Object



34
35
36
# File 'lib/outlog/base_logger.rb', line 34

def warn message, hash={}
  add ::Logger::WARN, message, hash
end