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
Interfaces, Classes and Traits
- EventSubscriberInterface
- An EventSubscriber knows itself what events it is interested in.
Table of Contents
- DEFAULT_FORMAT = '[{ts}] {method} {url} - {code} {phrase} - Retries: {retries}, Delay: {delay}, Time: {connect_time}, {total_time}, cURL: {curl_code} {curl_error}'
- $formatter : MessageFormatter
- $logger : LogAdapterInterface
- __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
Return values
mixed —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:
- ['eventName' => 'methodName']
- ['eventName' => ['methodName', $priority]]
- ['eventName' => [['methodName1', $priority], ['methodName2']]]
The code must not depend on runtime state as it will only be called at compile time. All logic depending on runtime state must be put into the individual methods handling the events.
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
Return values
mixed —setTemplate()
Set the template to use for logging
public
setTemplate(string $template) : self
Parameters
- $template : string
-
Log message template