Class Guzzle\Log\MessageFormatter


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)
  • {reqheader}: Replace `` with the lowercased name of a request header to add to the message
  • {resheader}: Replace `` with the lowercased name of a response header to add to the message
  • {req_body}: Request body
  • {res_body}: Response body

Protected Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$template string Template used to format log messages Guzzle\Log\MessageFormatter

Public Methods

Hide inherited methods

MethodDescriptionDefined By
__construct() Guzzle\Log\MessageFormatter
format() Returns a formatted message Guzzle\Log\MessageFormatter
setTemplate() Set the template to use for logging Guzzle\Log\MessageFormatter


Hide inherited constants

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

Property Details

$template protected property

Template used to format log messages

protected string $template null

Method Details

__construct() public method

public void __construct ( $template self::DEFAULT_FORMAT )
$template string

Log message template

format() public method

Returns a formatted message

public string format ( Guzzle\Http\Message\RequestInterface $request, Guzzle\Http\Message\Response $response null, Guzzle\Http\Curl\CurlHandle $handle null, array $customData = [] )
$request Guzzle\Http\Message\RequestInterface

Request that was sent

$response Guzzle\Http\Message\Response

Response that was received

$handle Guzzle\Http\Curl\CurlHandle

Curl handle associated with the message

$customData array

Associative array of custom template data

setTemplate() public method

Set the template to use for logging

public self setTemplate ( $template )
$template string

Log message template