Sha256: 4684210c5ae0d92060cd4505e0e7e3386e786e0c63b64d60b190a5fd1ccc5758

Contents?: true

Size: 1.06 KB

Versions: 35

Compression:

Stored size: 1.06 KB

Contents

require 'logger'

module Pact
  module MockService
    class Logger < ::Logger

      attr_reader :description

      def initialize stream
        super stream
        @description = if stream.is_a? File
           File.absolute_path(stream).gsub(Dir.pwd + "/", '')
        else
          "standard out/err"
        end
      end

      def self.from_options options
        log_stream = options[:log_file] || $stdout
        logger = new log_stream
        logger.formatter = options[:log_formatter] if options[:log_formatter]
        logger.level = logger_level(options[:log_level])
        logger
      end

      def self.logger_level log_level_string
        if log_level_string
          begin
            Kernel.const_get('Logger').const_get(log_level_string.upcase)
          rescue NameError
            $stderr.puts "WARN: Ignoring log level '#{log_level_string}' as it is not a valid value. Valid values are: DEBUG INFO WARN ERROR FATAL. Using DEBUG."
            Logger::DEBUG
          end
        else
          Logger::DEBUG
        end
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 2 rubygems

Version Path
pact-mock_service-3.12.3 lib/pact/mock_service/logger.rb
pact-mock_service-3.12.2 lib/pact/mock_service/logger.rb
pact-mock_service-3.12.1 lib/pact/mock_service/logger.rb
pact-mock_service-3.12.0 lib/pact/mock_service/logger.rb
pact-mock_service-3.11.2 lib/pact/mock_service/logger.rb
pact-mock_service-3.11.1 lib/pact/mock_service/logger.rb
pact-mock_service-3.11.0 lib/pact/mock_service/logger.rb
pact-mock_service-3.10.0 lib/pact/mock_service/logger.rb
hs-pact-mock_service-3.9.2 lib/pact/mock_service/logger.rb
pact-mock_service-3.9.1 lib/pact/mock_service/logger.rb
pact-mock_service-3.9.0 lib/pact/mock_service/logger.rb
pact-mock_service-3.8.0 lib/pact/mock_service/logger.rb
pact-mock_service-3.7.0 lib/pact/mock_service/logger.rb
pact-mock_service-3.6.2 lib/pact/mock_service/logger.rb
pact-mock_service-3.6.1 lib/pact/mock_service/logger.rb
pact-mock_service-3.6.0 lib/pact/mock_service/logger.rb
pact-mock_service-3.5.0 lib/pact/mock_service/logger.rb
pact-mock_service-3.4.0 lib/pact/mock_service/logger.rb
pact-mock_service-3.3.1 lib/pact/mock_service/logger.rb
pact-mock_service-3.3.0 lib/pact/mock_service/logger.rb