HTTP_Request2
[ class tree: HTTP_Request2 ] [ index: HTTP_Request2 ] [ all elements ]

Class: HTTP_Request2_Observer_Log

Source Location: /HTTP_Request2-2.2.1/HTTP/Request2/Observer/Log.php

Class Overview


A debug observer useful for debugging / testing.


Author(s):

Version:

  • Release: 2.2.1

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 70]
A debug observer useful for debugging / testing.

This observer logs to a log target data corresponding to the various request and response events, it logs by default to php://output but can be configured to log to a file or via the PEAR Log package.

A simple example:

  1.  require_once 'HTTP/Request2.php';
  2.  require_once 'HTTP/Request2/Observer/Log.php';
  3.  
  4.  $request  = new HTTP_Request2('http://www.example.com');
  5.  $observer = new HTTP_Request2_Observer_Log();
  6.  $request->attach($observer);
  7.  $request->send();

A more complex example with PEAR Log:

  1.  require_once 'HTTP/Request2.php';
  2.  require_once 'HTTP/Request2/Observer/Log.php';
  3.  require_once 'Log.php';
  4.  
  5.  $request  = new HTTP_Request2('http://www.example.com');
  6.  // we want to log with PEAR log
  7.  $observer = new HTTP_Request2_Observer_Log(Log::factory('console'));
  8.  
  9.  // we only want to log received headers
  10.  $observer->events = array('receivedHeaders');
  11.  
  12.  $request->attach($observer);
  13.  $request->send();



[ Top ]


Class Variables

$events = array(
        'connect',
        'sentHeaders',
        'sentBody',
        'receivedHeaders',
        'receivedBody',
        'disconnect',
    )

[line 86]

The events to log.
  • Access: public

Type:   array


[ Top ]

$target =  null

[line 79]

The log target, it can be a a resource or a PEAR Log instance.
  • Access: protected

Type:   resource|Log


[ Top ]



Method Detail

__construct (Constructor)   [line 107]

void __construct( [mixed $target = 'php://output'], [array $events = array()])

Constructor.
  • Access: public

Parameters:

mixed   $target   —  Can be a file path (default: php://output), a resource, or an instance of the PEAR Log class.
array   $events   —  Array of events to listen to (default: all events)

[ Top ]

log   [line 180]

void log( string $message)

Logs the given message to the configured target.
  • Access: protected

Parameters:

string   $message   —  Message to display

[ Top ]

update   [line 129]

void update( SplSubject $subject)

Called when the request notifies us of an event.
  • Access: public

Parameters:

HTTP_Request2   $subject   —  The HTTP_Request2 instance

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:56:02 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.