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

Public Member Functions

 __construct (LogAdapterInterface $logAdapter, $formatter=null, $wireBodies=false)
 
 onCurlRead (Event $event)
 
 onCurlWrite (Event $event)
 
 onRequestBeforeSend (Event $event)
 
 onRequestSent (Event $event)
 

Static Public Member Functions

static getDebugPlugin ($wireBodies=true, $stream=null)
 
static getSubscribedEvents ()
 

Protected Attributes

 $formatter
 
 $logAdapter
 
 $wireBodies
 

Detailed Description

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.

See also
MessageLogger for a list of available Log Template variable substitutions

Definition at line 20 of file LogPlugin.php.

Constructor & Destructor Documentation

◆ __construct()

Guzzle\Plugin\Log\LogPlugin::__construct ( LogAdapterInterface  $logAdapter,
  $formatter = null,
  $wireBodies = false 
)
Parameters
LogAdapterInterface$logAdapterAdapter object used to log message
string | MessageFormatter$formatterFormatter used to format log messages or the formatter template
bool$wireBodiesSet to true to track request and response bodies using a temporary buffer if the bodies are not repeatable.

Definition at line 46 of file LogPlugin.php.

References Guzzle\Plugin\Log\LogPlugin\$formatter, Guzzle\Plugin\Log\LogPlugin\$logAdapter, and Guzzle\Plugin\Log\LogPlugin\$wireBodies.

Member Function Documentation

◆ getDebugPlugin()

static Guzzle\Plugin\Log\LogPlugin::getDebugPlugin (   $wireBodies = true,
  $stream = null 
)
static

Get a log plugin that outputs full request, response, and curl error information to stderr

Parameters
bool$wireBodiesSet to false to disable request/response body output when they use are not repeatable
resource$streamStream to write to when logging. Defaults to STDERR when it is available
Returns
self

Definition at line 64 of file LogPlugin.php.

References Guzzle\Plugin\Log\LogPlugin\$wireBodies.

Referenced by Guzzle\Tests\Plugin\Log\LogPluginTest\testHasHelpfulStaticFactoryMethod().

◆ getSubscribedEvents()

static Guzzle\Plugin\Log\LogPlugin::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 79 of file LogPlugin.php.

◆ onCurlRead()

Guzzle\Plugin\Log\LogPlugin::onCurlRead ( Event  $event)

Event triggered when curl data is read from a request

Parameters
Event$event

Definition at line 94 of file LogPlugin.php.

◆ onCurlWrite()

Guzzle\Plugin\Log\LogPlugin::onCurlWrite ( Event  $event)

Event triggered when curl data is written to a response

Parameters
Event$event

Definition at line 107 of file LogPlugin.php.

◆ onRequestBeforeSend()

Guzzle\Plugin\Log\LogPlugin::onRequestBeforeSend ( Event  $event)

Called before a request is sent

Parameters
Event$event

Definition at line 120 of file LogPlugin.php.

References Guzzle\Http\EntityBody\factory(), and Guzzle\Http\Message\EntityEnclosingRequestInterface\getBody().

◆ onRequestSent()

Guzzle\Plugin\Log\LogPlugin::onRequestSent ( Event  $event)

Triggers the actual log write when a request completes

Parameters
Event$event

Definition at line 145 of file LogPlugin.php.

Field Documentation

◆ $formatter

MessageFormatter Guzzle\Plugin\Log\LogPlugin::$formatter
protected

Formatter used to format messages before logging

Definition at line 32 of file LogPlugin.php.

Referenced by Guzzle\Plugin\Log\LogPlugin\__construct().

◆ $logAdapter

LogAdapterInterface Guzzle\Plugin\Log\LogPlugin::$logAdapter
protected

Adapter responsible for writing log data

Definition at line 26 of file LogPlugin.php.

Referenced by Guzzle\Plugin\Log\LogPlugin\__construct().

◆ $wireBodies

bool Guzzle\Plugin\Log\LogPlugin::$wireBodies
protected

Whether or not to wire request and response bodies

Definition at line 38 of file LogPlugin.php.

Referenced by Guzzle\Plugin\Log\LogPlugin\__construct(), and Guzzle\Plugin\Log\LogPlugin\getDebugPlugin().


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