public function AcquiaPurgeExecutorBase::requestsLog in Acquia Purge 7
Log a series of requests according to their 'result' properties.
Parameters
AcquiaPurgeExecutorRequestInterface[] $requests: Unassociative list of ::requestsExecute() processed requests.
string $consequence: Appendable message determing what happens because of a failed request.
Overrides AcquiaPurgeExecutorInterface::requestsLog
1 call to AcquiaPurgeExecutorBase::requestsLog()
- AcquiaPurgeExecutorAcquia::invalidate in lib/
executor/ AcquiaPurgeExecutorAcquia.php - Invalidate one or multiple paths from an external layer.
File
- lib/
executor/ AcquiaPurgeExecutorBase.php, line 221 - Contains AcquiaPurgeExecutorBase.
Class
- AcquiaPurgeExecutorBase
- Provides an executor, which is responsible for taking a set of invalidation objects and wiping these paths/URLs from an external cache.
Code
public function requestsLog($requests, $consequence = 'goes back to queue!') {
$id = $this
->getId();
foreach ($requests as $r) {
$vars = array(
'%id' => $id,
'%uri' => $r->uri,
'%host' => parse_url($r->uri, PHP_URL_HOST),
'%method' => $r->method,
'%response_code' => $r->response_code,
);
if (isset($r->_host)) {
$vars['%uri'] = sprintf("%s (host=%s)", $r->uri, $r->_host);
}
// Log success or failure, depending on $r->result.
if ($r->result) {
if ($this->log_successes) {
watchdog('acquia_purge', "%id: %uri succeeded (%method, %response_code).", $vars, WATCHDOG_INFO);
}
}
else {
$vars['%path'] = $r->path;
$vars['%curl'] = (string) curl_strerror($r->error_curl);
$vars['%debug'] = $r->error_debug;
$vars['%timeout'] = AcquiaPurgeCapacity::HTTP_REQUEST_TIMEOUT;
switch ($r->error_curl) {
case CURLE_COULDNT_CONNECT:
$msg = "%id: unable to connect to %host, ";
$msg .= $consequence;
break;
case CURLE_COULDNT_RESOLVE_HOST:
$msg = "%id: cannot resolve host for %uri, ";
$msg .= $consequence;
break;
case CURLE_OPERATION_TIMEOUTED:
$msg = "%id: %uri exceeded %timeout sec., ";
$msg .= $consequence;
break;
case CURLE_URL_MALFORMAT:
$msg = "%id: %uri failed: URL malformed, ";
$msg .= $consequence;
$msg .= ' DEBUG: %debug';
break;
default:
$msg = "%id: %uri failed, ";
$msg .= $consequence;
$msg .= ' cURL: %curl; DEBUG: %debug';
break;
}
watchdog('acquia_purge', $msg, $vars, WATCHDOG_ERROR);
}
}
}