Sha256: 1588ab5487e0a8f69153ebfb71294730010cfa4f63b9568f06c3d914399b4139

Contents?: true

Size: 730 Bytes

Versions: 3

Compression:

Stored size: 730 Bytes

Contents

require 'logger'
module Voltos
  module Logger
    @@levels = ["FATAL", "ERROR", "WARN", "INFO", "DEBUG"]
    @@levels.each do |level|
      define_singleton_method level.downcase.to_sym do |msg|
        logger.send(level.downcase.to_sym, 'Voltos Process - ' + msg)
      end
    end

    def self.logger
      return @logger if @logger
      @logger = ::Logger.new(STDOUT)
      @logger.level = ::Logger::WARN
      if level = ENV["LOG_LEVEL"]
        if @@levels.include? level.upcase
          @logger.level = ::Logger.const_get(level.upcase.to_sym)
        else
          @logger.warn "Log level '#{level.upcase}' is unknown. Supported levels are: #{levels.join(", ")}."
        end
      end
      @logger
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
voltos-0.3.2 lib/voltos/logger.rb
voltos-0.3.0 lib/voltos/logger.rb
voltos-0.3.0.rc14 lib/voltos/logger.rb