Sha256: d13f247a462b456461fda76e41ea26c3506c0358a4743ef78803ce296a4bb115

Contents?: true

Size: 794 Bytes

Versions: 9

Compression:

Stored size: 794 Bytes

Contents

module MotionPrime
  class Logger
    LOGGER_ERROR_LEVEL = 0
    LOGGER_INFO_LEVEL = 1
    LOGGER_DEBUG_LEVEL = 2

    class_attribute :level

    def initialize
      @default_level = Config.logger.level.nil? ? :info : Config.logger.level
    end

    def error(*args)
      pp(*args) if LOGGER_ERROR_LEVEL <= current_level
    end

    def info(*args)
      pp(*args) if LOGGER_INFO_LEVEL <= current_level
    end

    def debug(*args)
      pp(*args) if LOGGER_DEBUG_LEVEL <= current_level
    end

    def current_level
      current_level = self.class.level || @default_level
      case current_level.to_s
      when 'error'
        LOGGER_ERROR_LEVEL
      when 'info'
        LOGGER_INFO_LEVEL
      when 'debug'
        LOGGER_DEBUG_LEVE
      else
        2
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
motion-prime-0.7.0 motion-prime/services/logger.rb
motion-prime-0.6.0 motion-prime/services/logger.rb
motion-prime-0.5.7 motion-prime/services/logger.rb
motion-prime-0.5.6 motion-prime/services/logger.rb
motion-prime-0.5.5 motion-prime/services/logger.rb
motion-prime-0.5.4 motion-prime/services/logger.rb
motion-prime-0.5.3 motion-prime/services/logger.rb
motion-prime-0.5.2 motion-prime/services/logger.rb
motion-prime-0.5.1 motion-prime/services/logger.rb