Class: Upfluence::Logger

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

Defined Under Namespace

Classes: Formatter

Instance Method Summary collapse

Constructor Details

#initialize(level = (ENV['LOGGER_LEVEL'] || '').downcase, caller_depth = 0) ⇒ Logger

Returns a new instance of Logger.



43
44
45
46
47
48
49
50
51
# File 'lib/upfluence/logger.rb', line 43

def initialize(level = (ENV['LOGGER_LEVEL'] || '').downcase, caller_depth = 0)
  $stdout.sync = true

  super(
    $stdout,
    level:     logger_level(level),
    formatter: Formatter.new(caller_depth)
  )
end

Instance Method Details

#logger_level(level) ⇒ Object



33
34
35
36
37
38
39
40
41
# File 'lib/upfluence/logger.rb', line 33

def logger_level(level)
  {
    'info' => Logger::INFO,
    'warn' => Logger::WARN,
    'debug' => Logger::DEBUG,
    'error' => Logger::ERROR,
    'fatal' => Logger::FATAL
  }[level] || Logger::INFO
end