BackoffLogger
in package
implements
EventSubscriberInterface
Logs backoff retries triggered from the BackoffPlugin
Format your log messages using a template that can contain template substitutions found in 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
Table of Contents
Interfaces
- EventSubscriberInterface
- An EventSubscriber knows himself what events he is interested in.
Constants
- DEFAULT_FORMAT = '[{ts}] {method} {url} - {code} {phrase} - Retries: {retries}, Delay: {delay}, Time: {connect_time}, {total_time}, cURL: {curl_code} {curl_error}'
Properties
Methods
- __construct() : mixed
- getSubscribedEvents() : array<string|int, mixed>
- Returns an array of event names this subscriber wants to listen to.
- onRequestRetry() : mixed
- Called when a request is being retried
- setTemplate() : self
- Set the template to use for logging
Constants
DEFAULT_FORMAT
public
string
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
Properties
$formatter
protected
MessageFormatter
$formatter
Formatter used to format log messages
$logger
protected
LogAdapterInterface
$logger
Logger used to log retries
Methods
__construct()
public
__construct(LogAdapterInterface $logger[, MessageFormatter $formatter = null ]) : mixed
Parameters
- $logger : LogAdapterInterface
-
Logger used to log the retries
- $formatter : MessageFormatter = null
-
Formatter used to format log messages
getSubscribedEvents()
Returns an array of event names this subscriber wants to listen to.
public
static getSubscribedEvents() : array<string|int, mixed>
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')))
Return values
array<string|int, mixed> —The event names to listen to
onRequestRetry()
Called when a request is being retried
public
onRequestRetry(Event $event) : mixed
Parameters
- $event : Event
-
Event emitted
setTemplate()
Set the template to use for logging
public
setTemplate(string $template) : self
Parameters
- $template : string
-
Log message template