protected function DebugCallGraphTrait::logFailedRequest in Varnish purger 8.2
Write an error to the log for a failed request.
Parameters
string $caller: Name of the PHP method that executed the request.
\Exception $e: The exception thrown by Guzzle.
2 calls to DebugCallGraphTrait::logFailedRequest()
- ZeroConfigPurger::getResultsConcurrently in src/
Plugin/ Purge/ Purger/ ZeroConfigPurger.php - Concurrently execute the given requests.
- ZeroConfigPurger::invalidateEverything in src/
Plugin/ Purge/ Purger/ ZeroConfigPurger.php - Invalidate the entire website.
File
- src/
DebugCallGraphTrait.php, line 157
Class
Namespace
Drupal\varnish_purgerCode
protected function logFailedRequest($caller, \Exception $e) {
$msg = "::@caller() -> @class:";
$vars = [
'@caller' => $caller,
'@class' => $this
->getClassName($e),
'@msg' => $e
->getMessage(),
];
// Add request information when this is present in the exception.
if ($e instanceof ConnectException) {
$vars['@msg'] = str_replace('(see http://curl.haxx.se/libcurl/c/libcurl-errors.html)', '', $e
->getMessage());
$vars['@msg'] .= '; This is allowed to happen accidentally when load' . ' balancers are slow. However, if all cache invalidations fail, your' . ' queue may stall and you should investigate with your hosting' . ' provider!';
}
elseif ($e instanceof RequestException) {
$req = $e
->getRequest();
$msg .= " HTTP @status; @method @uri;";
$vars['@uri'] = $req
->getUri();
$vars['@method'] = $req
->getMethod();
$vars['@status'] = $e
->hasResponse() ? $e
->getResponse()
->getStatusCode() : '???';
}
// Log the normal message to the emergency output stream.
/** @var \Drupal\purge\Logger\LoggerChannelPartInterface $logger */
$logger = $this
->logger();
$logger
->emergency("{$msg} @msg", $vars);
// In debugging mode, follow with quite some more data.
if ($logger
->isDebuggingEnabled()) {
$table = [
'exception' => get_class($e),
];
if ($e instanceof RequestException) {
$table = array_merge($table, $this
->debugInfoForRequest($e
->getRequest()));
$table['rsp'] = ($has_rsp = $e
->hasResponse()) ? 'YES' : 'No response';
if ($has_rsp && ($rsp = $e
->getResponse())) {
$table = array_merge($table, $this
->debugInfoForResponse($rsp, $e));
}
}
$this
->logDebugTable($table);
}
}