Sha256: a18f2510420f1c136936fbbe01d48b590fdf0e077ce7f154faa2e9bc85cd6ab8

Contents?: true

Size: 921 Bytes

Versions: 3

Compression:

Stored size: 921 Bytes

Contents

# -*- encoding : utf-8 -*-
require 'forwardable'

module Pacto
  module Logger
    def logger
      Pacto.configuration.logger
    end

    class SimpleLogger
      include Singleton
      extend Forwardable

      def_delegators :@log, :debug, :info, :warn, :error, :fatal

      def initialize
        log ::Logger.new STDOUT
      end

      def log(log)
        @log = log
        @log.level = default_level
        @log.progname = 'Pacto'
      end

      def level=(level)
        @log.level = log_levels.fetch(level, default_level)
      end

      def level
        log_levels.key @log.level
      end

      private

      def default_level
        ::Logger::ERROR
      end

      def log_levels
        {
          debug: ::Logger::DEBUG,
          info:  ::Logger::INFO,
          warn:  ::Logger::WARN,
          error: ::Logger::ERROR,
          fatal: ::Logger::FATAL
        }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pacto-0.4.0.rc3 lib/pacto/logger.rb
pacto-0.4.0.rc2 lib/pacto/logger.rb
pacto-0.4.0.rc1 lib/pacto/logger.rb