\Guzzle\LogMessageFormatter

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

Summary

Methods
Properties
Constants
__construct()
setTemplate()
format()
No public properties found
DEFAULT_FORMAT
DEBUG_FORMAT
SHORT_FORMAT
No protected methods found
$template
N/A
No private methods found
No private properties found
N/A

Constants

DEFAULT_FORMAT

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

DEBUG_FORMAT

DEBUG_FORMAT = ">>>>>>>>\n{request}\n<<<<<<<<\n{response}\n--------\n{curl_stderr}"

SHORT_FORMAT

SHORT_FORMAT = '[{ts}] "{method} {resource} {protocol}/{version}" {code}'

Properties

$template

$template : string

Type

string — Template used to format log messages

Methods

__construct()

__construct(string  $template = self::DEFAULT_FORMAT) 

Parameters

string $template

Log message template

setTemplate()

setTemplate(string  $template) : self

Set the template to use for logging

Parameters

string $template

Log message template

Returns

self

format()

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

Returns a formatted message

Parameters

\Guzzle\Http\Message\RequestInterface $request

Request that was sent

\Guzzle\Http\Message\Response $response

Response that was received

\Guzzle\Http\Curl\CurlHandle $handle

Curl handle associated with the message

array $customData

Associative array of custom template data

Returns

string