Edit File by line
/home/barbar84/www/wp-conte.../plugins/updraftp.../vendor/guzzle/guzzle/src/Guzzle/Plugin/Backoff
File: BackoffLogger.php
<?php
[0] Fix | Delete
[1] Fix | Delete
namespace Guzzle\Plugin\Backoff;
[2] Fix | Delete
[3] Fix | Delete
use Guzzle\Common\Event;
[4] Fix | Delete
use Guzzle\Log\LogAdapterInterface;
[5] Fix | Delete
use Guzzle\Log\MessageFormatter;
[6] Fix | Delete
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
[7] Fix | Delete
[8] Fix | Delete
/**
[9] Fix | Delete
* Logs backoff retries triggered from the BackoffPlugin
[10] Fix | Delete
*
[11] Fix | Delete
* Format your log messages using a template that can contain template substitutions found in {@see MessageFormatter}.
[12] Fix | Delete
* In addition to the default template substitutions, there is also:
[13] Fix | Delete
*
[14] Fix | Delete
* - retries: The number of times the request has been retried
[15] Fix | Delete
* - delay: The amount of time the request is being delayed
[16] Fix | Delete
*/
[17] Fix | Delete
class BackoffLogger implements EventSubscriberInterface
[18] Fix | Delete
{
[19] Fix | Delete
/** @var string Default log message template */
[20] Fix | Delete
const DEFAULT_FORMAT = '[{ts}] {method} {url} - {code} {phrase} - Retries: {retries}, Delay: {delay}, Time: {connect_time}, {total_time}, cURL: {curl_code} {curl_error}';
[21] Fix | Delete
[22] Fix | Delete
/** @var LogAdapterInterface Logger used to log retries */
[23] Fix | Delete
protected $logger;
[24] Fix | Delete
[25] Fix | Delete
/** @var MessageFormatter Formatter used to format log messages */
[26] Fix | Delete
protected $formatter;
[27] Fix | Delete
[28] Fix | Delete
/**
[29] Fix | Delete
* @param LogAdapterInterface $logger Logger used to log the retries
[30] Fix | Delete
* @param MessageFormatter $formatter Formatter used to format log messages
[31] Fix | Delete
*/
[32] Fix | Delete
public function __construct(LogAdapterInterface $logger, MessageFormatter $formatter = null)
[33] Fix | Delete
{
[34] Fix | Delete
$this->logger = $logger;
[35] Fix | Delete
$this->formatter = $formatter ?: new MessageFormatter(self::DEFAULT_FORMAT);
[36] Fix | Delete
}
[37] Fix | Delete
[38] Fix | Delete
public static function getSubscribedEvents()
[39] Fix | Delete
{
[40] Fix | Delete
return array(BackoffPlugin::RETRY_EVENT => 'onRequestRetry');
[41] Fix | Delete
}
[42] Fix | Delete
[43] Fix | Delete
/**
[44] Fix | Delete
* Set the template to use for logging
[45] Fix | Delete
*
[46] Fix | Delete
* @param string $template Log message template
[47] Fix | Delete
*
[48] Fix | Delete
* @return self
[49] Fix | Delete
*/
[50] Fix | Delete
public function setTemplate($template)
[51] Fix | Delete
{
[52] Fix | Delete
$this->formatter->setTemplate($template);
[53] Fix | Delete
[54] Fix | Delete
return $this;
[55] Fix | Delete
}
[56] Fix | Delete
[57] Fix | Delete
/**
[58] Fix | Delete
* Called when a request is being retried
[59] Fix | Delete
*
[60] Fix | Delete
* @param Event $event Event emitted
[61] Fix | Delete
*/
[62] Fix | Delete
public function onRequestRetry(Event $event)
[63] Fix | Delete
{
[64] Fix | Delete
$this->logger->log($this->formatter->format(
[65] Fix | Delete
$event['request'],
[66] Fix | Delete
$event['response'],
[67] Fix | Delete
$event['handle'],
[68] Fix | Delete
array(
[69] Fix | Delete
'retries' => $event['retries'],
[70] Fix | Delete
'delay' => $event['delay']
[71] Fix | Delete
)
[72] Fix | Delete
));
[73] Fix | Delete
}
[74] Fix | Delete
}
[75] Fix | Delete
[76] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function