\GuzzleHttpMessageFormatter

Formats log messages using variable substitutions for requests, responses, and other transactional data.

The following variable substitutions are supported:

  • {request}: Full HTTP request message
  • {response}: Full HTTP response message
  • {ts}: ISO 8601 date in GMT
  • {date_iso_8601} ISO 8601 date in GMT
  • {date_common_log} Apache common log date using the configured timezone.
  • {host}: Host of the request
  • {method}: Method of the request
  • {uri}: URI of the request
  • {host}: Host of the request
  • {version}: Protocol version
  • {target}: Request target of the request (path + query + fragment)
  • {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)
  • {error}: Any error messages (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_headers}: Request headers
  • {res_headers}: Response headers
  • {req_body}: Request body
  • {res_body}: Response body

Summary

Methods
Properties
Constants
__construct()
format()
No public properties found
CLF
DEBUG
SHORT
No protected methods found
No protected properties found
N/A
headers()
$template
N/A

Constants

CLF

CLF = "{hostname} {req_header_User-Agent} - [{date_common_log}] \"{method} {target} HTTP/{version}\" {code} {res_header_Content-Length}" : string

Apache Common Log Format.

DEBUG

DEBUG = ">>>>>>>>\n{request}\n<<<<<<<<\n{response}\n--------\n{error}"

SHORT

SHORT = '[{ts}] "{method} {target} HTTP/{version}" {code}'

Properties

$template

$template : string

Type

string — Template used to format log messages

Methods

__construct()

__construct(string  $template = self::CLF) 

Parameters

string $template

Log message template

format()

format(\Psr\Http\Message\RequestInterface  $request, \Psr\Http\Message\ResponseInterface  $response = null, \Exception  $error = null) : string

Returns a formatted message string.

Parameters

\Psr\Http\Message\RequestInterface $request

Request that was sent

\Psr\Http\Message\ResponseInterface $response

Response that was received

\Exception $error

Exception that was received

Returns

string