Open Journal Systems  3.3.0
Guzzle\Plugin\Backoff\BackoffLogger Class Reference
Inheritance diagram for Guzzle\Plugin\Backoff\BackoffLogger:
Symfony\Component\EventDispatcher\EventSubscriberInterface

Public Member Functions

 __construct (LogAdapterInterface $logger, MessageFormatter $formatter=null)
 
 onRequestRetry (Event $event)
 
 setTemplate ($template)
 

Static Public Member Functions

static getSubscribedEvents ()
 

Data Fields

const DEFAULT_FORMAT = '[{ts}] {method} {url} - {code} {phrase} - Retries: {retries}, Delay: {delay}, Time: {connect_time}, {total_time}, cURL: {curl_code} {curl_error}'
 

Protected Attributes

 $formatter
 
 $logger
 

Detailed Description

Logs backoff retries triggered from the BackoffPlugin

Format your log messages using a template that can contain template substitutions found in {

See also
MessageFormatter}. In addition to the default Template substitutions, there is also:
  • retries: The number of times the request has been retried
  • delay: The amount of time the request is being delayed

Definition at line 19 of file BackoffLogger.php.

Constructor & Destructor Documentation

◆ __construct()

Guzzle\Plugin\Backoff\BackoffLogger::__construct ( LogAdapterInterface  $logger,
MessageFormatter  $formatter = null 
)
Parameters
LogAdapterInterface$loggerLogger used to log the retries
MessageFormatter$formatterFormatter used to format log messages

Definition at line 40 of file BackoffLogger.php.

References Guzzle\Plugin\Backoff\BackoffLogger\$formatter, and Guzzle\Plugin\Backoff\BackoffLogger\$logger.

Member Function Documentation

◆ getSubscribedEvents()

static Guzzle\Plugin\Backoff\BackoffLogger::getSubscribedEvents ( )
static

Returns an array of event names this subscriber wants to listen to.

The array keys are event names and the value can be:

  • The method name to call (priority defaults to 0)
  • An array composed of the method name to call and the priority
  • An array of arrays composed of the method names to call and respective priorities, or 0 if unset

For instance:

  • array('eventName' => 'methodName')
  • array('eventName' => array('methodName', $priority))
  • array('eventName' => array(array('methodName1', $priority), array('methodName2')))
Returns
array The event names to listen to

Implements Symfony\Component\EventDispatcher\EventSubscriberInterface.

Definition at line 46 of file BackoffLogger.php.

References Guzzle\Plugin\Backoff\BackoffPlugin\RETRY_EVENT.

Referenced by Guzzle\Tests\Plugin\Backoff\BackoffLoggerTest\testHasEventList().

◆ onRequestRetry()

Guzzle\Plugin\Backoff\BackoffLogger::onRequestRetry ( Event  $event)

Called when a request is being retried

Parameters
Event$eventEvent emitted

Definition at line 70 of file BackoffLogger.php.

◆ setTemplate()

Guzzle\Plugin\Backoff\BackoffLogger::setTemplate (   $template)

Set the template to use for logging

Parameters
string$templateLog message template
Returns
self

Definition at line 58 of file BackoffLogger.php.

Field Documentation

◆ $formatter

MessageFormatter Guzzle\Plugin\Backoff\BackoffLogger::$formatter
protected

Formatter used to format log messages

Definition at line 34 of file BackoffLogger.php.

Referenced by Guzzle\Plugin\Backoff\BackoffLogger\__construct().

◆ $logger

string Guzzle\Plugin\Backoff\BackoffLogger::$logger
protected

Definition at line 28 of file BackoffLogger.php.

Referenced by Guzzle\Plugin\Backoff\BackoffLogger\__construct().

◆ DEFAULT_FORMAT

const Guzzle\Plugin\Backoff\BackoffLogger::DEFAULT_FORMAT = '[{ts}] {method} {url} - {code} {phrase} - Retries: {retries}, Delay: {delay}, Time: {connect_time}, {total_time}, cURL: {curl_code} {curl_error}'

Default log message template

Definition at line 23 of file BackoffLogger.php.


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