Sha256: 5a5a8b576eb484635ff6ce6c739b6bfcc2f264c22fcc9d91c0b566ead9f65fb8

Contents?: true

Size: 684 Bytes

Versions: 16

Compression:

Stored size: 684 Bytes

Contents

module HTTParty
  module Logger
    class ApacheLogger #: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['Content-Length']
        @logger.send @level, "[#{TAG_NAME}] [#{current_time}] #{response.code} \"#{http_method} #{path}\" #{content_length || "-"} "
      end
    end
  end
end

Version data entries

16 entries across 15 versions & 5 rubygems

Version Path
alloy_sdk-0.1.0 vendor/bundle/ruby/3.0.0/gems/httparty-0.13.1/lib/httparty/logger/apache_logger.rb
alloy_sdk-0.1.0 vendor/bundle/ruby/2.6.0/gems/httparty-0.13.1/lib/httparty/logger/apache_logger.rb
allegro_api_client-0.0.9 gems/ruby/2.1.0/gems/httparty-0.13.1/lib/httparty/logger/apache_logger.rb
allegro_api_client-0.0.8 gems/ruby/2.1.0/gems/httparty-0.13.1/lib/httparty/logger/apache_logger.rb
allegro_api_client-0.0.7 gems/ruby/2.1.0/gems/httparty-0.13.1/lib/httparty/logger/apache_logger.rb
asana2flowdock-1.0.0 vendor/bundle/ruby/1.9.1/gems/httparty-0.13.1/lib/httparty/logger/apache_logger.rb
allegro_api_client-0.0.6 gems/ruby/2.1.0/gems/httparty-0.13.1/lib/httparty/logger/apache_logger.rb
allegro_api_client-0.0.5 gems/ruby/2.1.0/gems/httparty-0.13.1/lib/httparty/logger/apache_logger.rb
allegro_api_client-0.0.4 gems/ruby/2.1.0/gems/httparty-0.13.1/lib/httparty/logger/apache_logger.rb
allegro_api_client-0.0.3 gems/ruby/2.1.0/gems/httparty-0.13.1/lib/httparty/logger/apache_logger.rb
allegro_api_client-0.0.2 gems/ruby/2.1.0/gems/httparty-0.13.1/lib/httparty/logger/apache_logger.rb
allegro_api_client-0.0.1 gems/ruby/2.1.0/gems/httparty-0.13.1/lib/httparty/logger/apache_logger.rb
httparty-0.13.1 lib/httparty/logger/apache_logger.rb
yoyle439587298-0.13.0 lib/httparty/logger/apache_logger.rb
httparty-0.13.0 lib/httparty/logger/apache_logger.rb
httparty-0.12.0 lib/httparty/logger/apache_logger.rb