Sha256: e7cd3a634bc17db1b0c195e5b69cde375b92bf1ffe716a152d075a992fdcbd81

Contents?: true

Size: 794 Bytes

Versions: 3

Compression:

Stored size: 794 Bytes

Contents

require 'logger'
require 'pra/config'
require 'date'

module Pra
  class Log
    def self.logger
      @logger ||= begin 
        logger = Logger.new(Pra::Config.log_path, 10, 5000000)
        logger.formatter = proc { |severity, datetime, progname, msg|
          "#{datetime.iso8601} #{severity} - #{msg}\n"
        }
        logger.level = Logger::INFO
        logger
      end
    end

    def self.level(level)
      logger.level = Logger.const_get level.upcase
    end

    def self.info(message)
      logger.info(message)
    end

    def self.debug(message)
      logger.debug(message)
    end
    
    def self.error(message)
      logger.error(message)
      if message.respond_to?(:backtrace)
        message.backtrace.each { |line| logger.error(line) }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pra-3.0.0 lib/pra/log.rb
pra-2.1.0 lib/pra/log.rb
pra-2.0.0 lib/pra/log.rb