Class: Geocoder::Logger

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/geocoder/logger.rb

Constant Summary collapse

SEVERITY =
{
  debug: ::Logger::DEBUG,
  info: ::Logger::INFO,
  warn: ::Logger::WARN,
  error: ::Logger::ERROR,
  fatal: ::Logger::FATAL
}

Instance Method Summary collapse

Instance Method Details

#log(level, message) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/geocoder/logger.rb', line 20

def log(level, message)
  unless valid_level?(level)
    raise StandardError, "Geocoder tried to log a message with an invalid log level."
  end
  if current_logger.respond_to? :add
    current_logger.add(SEVERITY[level], message)
  else
    raise Geocoder::ConfigurationError, "Please specify valid logger for Geocoder. " +
    "Logger specified must be :kernel or must respond to `add(level, message)`."
  end
  nil
end