Open Journal Systems  3.3.0
Guzzle\Log\MessageFormatter Class Reference

Public Member Functions

 __construct ($template=self::DEFAULT_FORMAT)
 
 format (RequestInterface $request, Response $response=null, CurlHandle $handle=null, array $customData=array())
 
 setTemplate ($template)
 

Data Fields

const DEBUG_FORMAT = ">>>>>>>>\n{request}\n<<<<<<<<\n{response}\n--------\n{curl_stderr}"
 
const DEFAULT_FORMAT = "{hostname} {req_header_User-Agent} - [{ts}] \"{method} {resource} {protocol}/{version}\" {code} {res_header_Content-Length}"
 
const SHORT_FORMAT = '[{ts}] "{method} {resource} {protocol}/{version}" {code}'
 

Protected Attributes

 $template
 

Detailed Description

Message formatter used in various places in the framework

Format messages using a template that can contain the the following variables:

  • {request}: Full HTTP request message
  • {response}: Full HTTP response message
  • {ts}: Timestamp
  • {host}: Host of the request
  • {method}: Method of the request
  • {url}: URL of the request
  • {host}: Host of the request
  • {protocol}: Request protocol
  • {version}: Protocol version
  • {resource}: Resource of the request (path + query + fragment)
  • {port}: Port of the request
  • {hostname}: Hostname of the machine that sent the request
  • {code}: Status code of the response (if available)
  • {phrase}: Reason phrase of the response (if available)
  • {curl_error}: Curl error message (if available)
  • {curl_code}: Curl error code (if available)
  • {curl_stderr}: Curl standard error (if available)
  • {connect_time}: Time in seconds it took to establish the connection (if available)
  • {total_time}: Total transaction time in seconds for last transfer (if available)
  • {req_header_*}: Replace * with the lowercased name of a request header to add to the message
  • {res_header_*}: Replace * with the lowercased name of a response header to add to the message
  • {req_body}: Request body
  • {res_body}: Response body

Definition at line 39 of file lib/vendor/guzzle/guzzle/src/Guzzle/Log/MessageFormatter.php.

Constructor & Destructor Documentation

◆ __construct()

Guzzle\Log\MessageFormatter::__construct (   $template = self::DEFAULT_FORMAT)

Member Function Documentation

◆ format()

Guzzle\Log\MessageFormatter::format ( RequestInterface  $request,
Response  $response = null,
CurlHandle  $handle = null,
array  $customData = array() 
)

Returns a formatted message

Parameters
RequestInterface$requestRequest that was sent
Response$responseResponse that was received
CurlHandle$handleCurl handle associated with the message
array$customDataAssociative array of custom template data
Returns
string

Definition at line 85 of file lib/vendor/guzzle/guzzle/src/Guzzle/Log/MessageFormatter.php.

References Guzzle\Log\MessageFormatter\$template, Guzzle\Http\Message\MessageInterface\getHeader(), Guzzle\Http\Message\RequestInterface\getHost(), Guzzle\Http\Message\RequestInterface\getMethod(), Guzzle\Http\Message\RequestInterface\getPort(), Guzzle\Http\Message\RequestInterface\getProtocolVersion(), Guzzle\Http\Message\RequestInterface\getResource(), and Guzzle\Http\Message\RequestInterface\getUrl().

◆ setTemplate()

Guzzle\Log\MessageFormatter::setTemplate (   $template)

Set the template to use for logging

Parameters
string$templateLog message template
Returns
self

Definition at line 68 of file lib/vendor/guzzle/guzzle/src/Guzzle/Log/MessageFormatter.php.

References Guzzle\Log\MessageFormatter\$template.

Field Documentation

◆ $template

string Guzzle\Log\MessageFormatter::$template
protected

◆ DEBUG_FORMAT

const Guzzle\Log\MessageFormatter::DEBUG_FORMAT = ">>>>>>>>\n{request}\n<<<<<<<<\n{response}\n--------\n{curl_stderr}"

◆ DEFAULT_FORMAT

const Guzzle\Log\MessageFormatter::DEFAULT_FORMAT = "{hostname} {req_header_User-Agent} - [{ts}] \"{method} {resource} {protocol}/{version}\" {code} {res_header_Content-Length}"

◆ SHORT_FORMAT

const Guzzle\Log\MessageFormatter::SHORT_FORMAT = '[{ts}] "{method} {resource} {protocol}/{version}" {code}'

The documentation for this class was generated from the following file: