Class: SoraGeocoding::Logger
- Inherits:
-
Object
- Object
- SoraGeocoding::Logger
- Includes:
- Singleton
- Defined in:
- lib/sora_geocoding/logger.rb
Overview
Logger
Constant Summary collapse
- LOG_LEVEL =
{ debug: ::Logger::DEBUG, info: ::Logger::INFO, warn: ::Logger::WARN, error: ::Logger::ERROR, fatal: ::Logger::FATAL }.freeze
Instance Method Summary collapse
Instance Method Details
#add(level, message) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/sora_geocoding/logger.rb', line 35 def add(level, ) return unless (level) case level when ::Logger::DEBUG, ::Logger::INFO puts when ::Logger::WARN warn when ::Logger::ERROR raise when ::Logger::FATAL raise end end |
#log(level, message) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/sora_geocoding/logger.rb', line 23 def log(level, ) raise StandardError, 'SoraGeocoding tried to log a message with an invalid log level.' unless valid_level?(level) if respond_to?(:add) add(LOG_LEVEL[level], ) else raise SoraGeocoding::ConfigurationError, 'Please specify valid logger for SoraGeocoding. ' \ 'Logger specified must respond to `add(level, message)`.' end nil end |