LogPlugin
in package
implements
EventSubscriberInterface
Plugin class that will add request and response logging to an HTTP request.
The log plugin uses a message formatter that allows custom messages via template variable substitution.
Tags
Table of Contents
Interfaces
- EventSubscriberInterface
- An EventSubscriber knows himself what events he is interested in.
Properties
Methods
- __construct() : mixed
- getDebugPlugin() : self
- Get a log plugin that outputs full request, response, and curl error information to stderr
- getSubscribedEvents() : array<string|int, mixed>
- Returns an array of event names this subscriber wants to listen to.
- onCurlRead() : mixed
- Event triggered when curl data is read from a request
- onCurlWrite() : mixed
- Event triggered when curl data is written to a response
- onRequestBeforeSend() : mixed
- Called before a request is sent
- onRequestSent() : mixed
- Triggers the actual log write when a request completes
Properties
$formatter
protected
MessageFormatter
$formatter
Formatter used to format messages before logging
$logAdapter
protected
LogAdapterInterface
$logAdapter
Adapter responsible for writing log data
$wireBodies
protected
bool
$wireBodies
Whether or not to wire request and response bodies
Methods
__construct()
public
__construct(LogAdapterInterface $logAdapter[, string|MessageFormatter $formatter = null ][, bool $wireBodies = false ]) : mixed
Parameters
- $logAdapter : LogAdapterInterface
-
Adapter object used to log message
- $formatter : string|MessageFormatter = null
-
Formatter used to format log messages or the formatter template
- $wireBodies : bool = false
-
Set to true to track request and response bodies using a temporary buffer if the bodies are not repeatable.
getDebugPlugin()
Get a log plugin that outputs full request, response, and curl error information to stderr
public
static getDebugPlugin([bool $wireBodies = true ][, resource $stream = null ]) : self
Parameters
- $wireBodies : bool = true
-
Set to false to disable request/response body output when they use are not repeatable
- $stream : resource = null
-
Stream to write to when logging. Defaults to STDERR when it is available
Return values
selfgetSubscribedEvents()
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
onCurlRead()
Event triggered when curl data is read from a request
public
onCurlRead(Event $event) : mixed
Parameters
- $event : Event
onCurlWrite()
Event triggered when curl data is written to a response
public
onCurlWrite(Event $event) : mixed
Parameters
- $event : Event
onRequestBeforeSend()
Called before a request is sent
public
onRequestBeforeSend(Event $event) : mixed
Parameters
- $event : Event
onRequestSent()
Triggers the actual log write when a request completes
public
onRequestSent(Event $event) : mixed
Parameters
- $event : Event