Open Monograph Press  3.3.0
GuzzleHttp\MessageFormatter Class Reference

Public Member Functions

 __construct ($template=self::CLF)
 
 format (RequestInterface $request, ResponseInterface $response=null, \Exception $error=null)
 

Data Fields

const CLF = "{hostname} {req_header_User-Agent} - [{date_common_log}] \"{method} {target} HTTP/{version}\" {code} {res_header_Content-Length}"
 
const DEBUG = ">>>>>>>>\n{request}\n<<<<<<<<\n{response}\n--------\n{error}"
 
const SHORT = '[{ts}] "{method} {target} HTTP/{version}" {code}'
 

Detailed Description

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

Definition at line 35 of file vendor/guzzlehttp/guzzle/src/MessageFormatter.php.

Constructor & Destructor Documentation

◆ __construct()

GuzzleHttp\MessageFormatter::__construct (   $template = self::CLF)
Parameters
string$templateLog message template

Definition at line 55 of file vendor/guzzlehttp/guzzle/src/MessageFormatter.php.

Member Function Documentation

◆ format()

GuzzleHttp\MessageFormatter::format ( RequestInterface  $request,
ResponseInterface  $response = null,
\Exception  $error = null 
)

Returns a formatted message string.

Parameters
RequestInterface$requestRequest that was sent
ResponseInterface$responseResponse that was received
\Exception$errorException that was received
Returns
string

Definition at line 69 of file vendor/guzzlehttp/guzzle/src/MessageFormatter.php.

Referenced by GuzzleHttp\Middleware\log().

Field Documentation

◆ CLF

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

◆ DEBUG

const GuzzleHttp\MessageFormatter::DEBUG = ">>>>>>>>\n{request}\n<<<<<<<<\n{response}\n--------\n{error}"

◆ SHORT

const GuzzleHttp\MessageFormatter::SHORT = '[{ts}] "{method} {target} HTTP/{version}" {code}'

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