Sha256: 027a64eb445472fe8e8d30efa88db341ad42127a7238f0e5ecb56e3a9897e981

Contents?: true

Size: 757 Bytes

Versions: 17

Compression:

Stored size: 757 Bytes

Contents

module HTTParty
  module Logger
    class ApacheFormatter #:nodoc:
      TAG_NAME = HTTParty.name

      attr_accessor :level, :logger, :current_time

      def initialize(logger, level)
        @logger = logger
        @level  = level.to_sym
      end

      def format(request, response)
        current_time   = Time.now.strftime("%Y-%m-%d %H:%M:%S %z")
        http_method    = request.http_method.name.split("::").last.upcase
        path           = request.path.to_s
        content_length = response.respond_to?(:headers) ? response.headers['Content-Length'] : response['Content-Length']
        @logger.send @level, "[#{TAG_NAME}] [#{current_time}] #{response.code} \"#{http_method} #{path}\" #{content_length || '-'} "
      end
    end
  end
end

Version data entries

17 entries across 16 versions & 3 rubygems

Version Path
httparty-0.16.2 lib/httparty/logger/apache_formatter.rb
httparty-0.16.1 lib/httparty/logger/apache_formatter.rb
httparty-0.16.0 lib/httparty/logger/apache_formatter.rb
httparty-0.15.7 lib/httparty/logger/apache_formatter.rb
httparty-0.15.6 lib/httparty/logger/apache_formatter.rb
httparty-0.15.5 lib/httparty/logger/apache_formatter.rb
httparty-0.15.4 lib/httparty/logger/apache_formatter.rb
httparty-0.15.3 lib/httparty/logger/apache_formatter.rb
httparty-0.15.2 lib/httparty/logger/apache_formatter.rb
httparty-0.15.1 lib/httparty/logger/apache_formatter.rb
httparty-0.15.0 lib/httparty/logger/apache_formatter.rb
httparty-0.14.0 lib/httparty/logger/apache_formatter.rb
simplenet-client-0.2.0 ./vendor/bundle/ruby/2.0.0/gems/httparty-0.13.7/lib/httparty/logger/apache_formatter.rb
simplenet-client-0.2.0 ./vendor/bundle/ruby/1.9.1/gems/httparty-0.13.7/lib/httparty/logger/apache_formatter.rb
httparty-0.13.7 lib/httparty/logger/apache_formatter.rb
httparty-0.13.6 lib/httparty/logger/apache_formatter.rb
httpserious-0.13.5.lstoll1 lib/httparty/logger/apache_formatter.rb