Class: HTTParty::Logger::CurlFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/httparty/logger/curl_formatter.rb

Overview

:nodoc:

Constant Summary collapse

TAG_NAME =
HTTParty.name
OUT =
'>'.freeze
IN =
'<'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(logger, level) ⇒ CurlFormatter

Returns a new instance of CurlFormatter


10
11
12
13
14
# File 'lib/httparty/logger/curl_formatter.rb', line 10

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

Instance Attribute Details

#levelObject

Returns the value of attribute level


8
9
10
# File 'lib/httparty/logger/curl_formatter.rb', line 8

def level
  @level
end

#loggerObject

Returns the value of attribute logger


8
9
10
# File 'lib/httparty/logger/curl_formatter.rb', line 8

def logger
  @logger
end

Instance Method Details

#format(request, response) ⇒ Object


16
17
18
19
20
21
22
23
24
# File 'lib/httparty/logger/curl_formatter.rb', line 16

def format(request, response)
  @request  = request
  @response = response

  log_request
  log_response

  logger.public_send level, messages.join("\n")
end