Sha256: 57a712ce16a08f08858cd3a0b627c8a9a006f7b25157733c29cdfc248550336d

Contents?: true

Size: 867 Bytes

Versions: 18

Compression:

Stored size: 867 Bytes

Contents

require 'logger'
require 'fileutils'

module Soaspec

  # Handles logs of API requests and responses
  class SpecLogger
    class << self
      def create
        unless File.exist?('logs/traffic.log')
          FileUtils.mkdir_p 'logs'
          FileUtils.touch File.join('logs', 'traffic.log')
        end
        @logger = Logger.new('logs/traffic.log') # Where request and responses of APIs are stored
        @logger.level = Logger::DEBUG
        @logger
      end

      # Log a message using Soaspec logger
      # @param [String] message The message to add to the logger
      def info(message)
        return unless Soaspec.log_api_traffic?
        if message.respond_to? :each
          message.each do |message_item|
            @logger.info(message_item)
          end
        else
          @logger.info(message)
        end
      end
    end

  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
soaspec-0.2.5 lib/soaspec/spec_logger.rb
soaspec-0.2.4 lib/soaspec/spec_logger.rb
soaspec-0.2.3 lib/soaspec/spec_logger.rb
soaspec-0.2.2 lib/soaspec/spec_logger.rb
soaspec-0.2.1 lib/soaspec/spec_logger.rb
soaspec-0.2.0 lib/soaspec/spec_logger.rb
soaspec-0.1.18 lib/soaspec/spec_logger.rb
soaspec-0.1.17 lib/soaspec/spec_logger.rb
soaspec-0.1.16 lib/soaspec/spec_logger.rb
soaspec-0.1.15 lib/soaspec/spec_logger.rb
soaspec-0.1.14 lib/soaspec/spec_logger.rb
soaspec-0.1.13 lib/soaspec/spec_logger.rb
soaspec-0.1.12 lib/soaspec/spec_logger.rb
soaspec-0.1.11 lib/soaspec/spec_logger.rb
soaspec-0.1.10 lib/soaspec/spec_logger.rb
soaspec-0.1.9 lib/soaspec/spec_logger.rb
soaspec-0.1.8 lib/soaspec/spec_logger.rb
soaspec-0.1.7 lib/soaspec/spec_logger.rb