Sha256: 0a9df328533cb81a7e9179e0efee09ca863dc397fe3604c92be05d9a8618ac8f

Contents?: true

Size: 888 Bytes

Versions: 1

Compression:

Stored size: 888 Bytes

Contents

module Heirloom
  class HeirloomLogger
    
    def initialize(args = {})
      @logger = args[:logger] ||= Logger.new(STDOUT)
      @log_level = args[:log_level] ||= 'info'

      unless args[:logger]
        @logger.datetime_format = "%Y-%m-%d %H:%M:%S"
        @logger.formatter = proc do |severity, datetime, progname, msg|
            "#{datetime}: #{msg}\n"
        end
      end

      case @log_level.downcase
      when 'info'
        @logger.level = Logger::INFO
      when 'debug'
        @logger.level = Logger::DEBUG
      when 'warn'
        @logger.level = Logger::WARN
      when 'error'
        @logger.level = Logger::ERROR
      end
      @logger
    end

    def debug(msg)
      @logger.debug msg
    end

    def info(msg)
      @logger.info msg
    end

    def error(msg)
      @logger.error msg
    end

    def info(msg)
      @logger.info msg
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
heirloom-0.2.0 lib/heirloom/logger.rb