Sha256: 1f402212129f7093b218f620dbc99d02a720d3c6c9b770009425897a976d2000

Contents?: true

Size: 649 Bytes

Versions: 12

Compression:

Stored size: 649 Bytes

Contents

module HTTParty
  module Logging
    def self.logging_env
      ENV["HTTPARTY_LOGGING"]
    end
    
    def self.enabled?
      logging_env
    end

    def self.destination
      unless @destination
        if(logging_env == "stdout")
          @destination = STDOUT
        else
          @destination = File.open(logging_env, 'a')
          at_exit{@destination.close}
        end
      end
      @destination
    end
    
    def self.log(string)
      destination.puts(string)
    end
    
    def record_log
      if Logging.enabled?
        record = []
        yield(record)
        Logging.log(record.join("\n"))
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
spreedly-1.3.5 vendor/httparty/lib/httparty/logging.rb
spreedly-1.3.4 vendor/httparty/lib/httparty/logging.rb
spreedly-1.3.3 vendor/httparty/lib/httparty/logging.rb
spreedly-1.3.2 vendor/httparty/lib/httparty/logging.rb
spreedly-1.3.1 vendor/httparty/lib/httparty/logging.rb
spreedly-1.0.0 vendor/httparty/lib/httparty/logging.rb
spreedly-1.0.1 vendor/httparty/lib/httparty/logging.rb
spreedly-1.2.2 vendor/httparty/lib/httparty/logging.rb
spreedly-1.2.0 vendor/httparty/lib/httparty/logging.rb
spreedly-1.1.0 vendor/httparty/lib/httparty/logging.rb
spreedly-1.3.0 vendor/httparty/lib/httparty/logging.rb
spreedly-1.2.1 vendor/httparty/lib/httparty/logging.rb