Module: Logging

Defined in:
lib/dinosaurus/logging.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.infer_level(level = nil) ⇒ Object

infer a suitable Log level from the ENVIRONMENT variable Can pass in an environment value for testing purposes


18
19
20
21
22
23
24
25
# File 'lib/dinosaurus/logging.rb', line 18

def self.infer_level(level = nil)
  level = level || Dinosaurus.configuration.log_level
  case level
  when 'debug' then Logger::DEBUG
  when 'warn' then Logger::WARN
  else Logger::INFO # default
  end
end

.loggerObject


8
9
10
11
12
13
14
# File 'lib/dinosaurus/logging.rb', line 8

def self.logger
  unless @logger
    @logger = Logger.new(STDOUT)
    @logger.level = Logging.infer_level
  end
  @logger
end

Instance Method Details

#loggerObject


4
5
6
# File 'lib/dinosaurus/logging.rb', line 4

def logger
  Logging.logger
end