Plop
A simple logging library for PHP
Plop\HandlerAbstract Class Reference

An abstract class that can be used as a base to create new log records handlers. More...

+ Inheritance diagram for Plop\HandlerAbstract:

Public Member Functions

 __construct (\Plop\FormatterInterface $formatter=null,\Plop\FiltersCollectionAbstract $filters=null)
 
 getFilters ()
 
 getFormatter ()
 
 handle (\Plop\RecordInterface $record)
 
 handleError (\Plop\RecordInterface $record,\Exception $exception)
 
 setFilters (\Plop\FiltersCollectionAbstract $filters)
 
 setFormatter (\Plop\FormatterInterface $formatter)
 

Protected Member Functions

 emit (\Plop\RecordInterface $record)
 
 format (\Plop\RecordInterface $record)
 
 getStderr ()
 

Protected Attributes

 $filters
 An object handling a collection of filters.
 
 $formatter
 Formatter object to use for this handler.
 

Detailed Description

An abstract class that can be used as a base to create new log records handlers.

Subclasses must implement the _emit() method.

Definition at line 30 of file HandlerAbstract.php.

Constructor & Destructor Documentation

Plop\HandlerAbstract::__construct ( \Plop\FormatterInterface  $formatter = null,
\Plop\FiltersCollectionAbstract  $filters = null 
)

Create a new handler that accepts any log record.

Parameters
Plop::FormatterInterface$formatter(optional) The formatter this handler will use to render records. By default, a new instance of Plop::Formatter is created.
Plop::FiltersCollectionAbstract$filters(optional) A collection of filters to associate with this handler. Defaults to an empty list.

Definition at line 50 of file HandlerAbstract.php.

Member Function Documentation

Plop\HandlerAbstract::emit ( \Plop\RecordInterface  $record)
abstractprotected

Send the log to its final destination.

Parameters
Plop::RecordInterface$recordThe record to log.
Returns
This method does not return any value.
Plop\HandlerAbstract::format ( \Plop\RecordInterface  $record)
protected

Format a record.

Parameters
Plop::RecordInterface$recordThe record to format.
Return values
stringFormatted representation of the record.

Definition at line 99 of file HandlerAbstract.php.

Referenced by Plop\Handler\Stream\emit(), Plop\Handler\SysLog\emit(), and Plop\Handler\RotatingFile\shouldRollover().

Plop\HandlerAbstract::getFilters ( )

Get the collection of filters currently associated with this handler.

Return values
Plop::FiltersCollectionAbstractCollection of filters associated with this handler.

Implements Plop\HandlerInterface.

Definition at line 78 of file HandlerAbstract.php.

Plop\HandlerAbstract::getFormatter ( )

Return the formatter used by this handler.

Return values
Plop::FormatterInterfaceFormatter object used by this handler.

Implements Plop\HandlerInterface.

Definition at line 65 of file HandlerAbstract.php.

Plop\HandlerAbstract::getStderr ( )
protected

Return STDERR as a (closable) stream. This method only exists to provide an easy way to mock STDERR in unit tests.

Return values
resourceSTDERR as a closable stream.

Definition at line 135 of file HandlerAbstract.php.

Plop\HandlerAbstract::handle ( \Plop\RecordInterface  $record)

Handle a log record.

Parameters
Plop::RecordInterface$recordThe log record to handle.
Return values
Plop::HandlerInterfaceThe handler instance (ie. $this).

Implements Plop\HandlerInterface.

Definition at line 116 of file HandlerAbstract.php.

Plop\HandlerAbstract::handleError ( \Plop\RecordInterface  $record,
\Exception  $exception 
)

Handle an exception that occurred during log record handling.

Parameters
Plop::RecordInterface$recordThe log record that was being handled when the exception occurred.
Exception$exceptionThe actual exception.
Return values
Plop::HandlerInterfaceThe handler instance (ie. $this).

Implements Plop\HandlerInterface.

Definition at line 141 of file HandlerAbstract.php.

Referenced by Plop\Handler\RotatingAbstract\emit(), and Plop\Handler\SysLog\emit().

Plop\HandlerAbstract::setFilters ( \Plop\FiltersCollectionAbstract  $filters)

Set the collection of filters associated with this handler.

Parameters
Plop::FiltersCollectionAbstract$filtersNew collection of filters to associate with this handler.
Return values
Plop::HandlerInterfaceThe handler instance (ie. $this).

Implements Plop\HandlerInterface.

Definition at line 84 of file HandlerAbstract.php.

Plop\HandlerAbstract::setFormatter ( \Plop\FormatterInterface  $formatter)

Set the new formatter to use.

Parameters
Plop::FormatterInterface$formatterThe new formatter object to use to format log records.
Return values
Plop::HandlerInterfaceThe handler instance (ie. $this).

Implements Plop\HandlerInterface.

Definition at line 71 of file HandlerAbstract.php.


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