Skip to content

Instantly share code, notes, and snippets.

@catwhocode
Created July 9, 2024 05:09
Show Gist options
  • Save catwhocode/1ddace704529273896b2b32e6028d983 to your computer and use it in GitHub Desktop.
Save catwhocode/1ddace704529273896b2b32e6028d983 to your computer and use it in GitHub Desktop.
Guzzle Message Formatter Supported Variable Substitution
/**
* source:
* https://github.com/guzzle/guzzle/blob/7.5/src/MessageFormatter.php#L12
*
* 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
* - {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)
* - {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_headers}: Request headers
* - {res_headers}: Response headers
* - {req_body}: Request body
* - {res_body}: Response body
*
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment