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

A class that provides logging capabilities. More...

+ Inheritance diagram for Plop\Logger:

Public Member Functions

 __construct ($ns=null, $cls=null, $method=null,\Plop\HandlersCollectionAbstract $handlers=null,\Plop\FiltersCollectionAbstract $filters=null)
 
 getClass ()
 
 getFilters ()
 
 getHandlers ()
 
 getLevel ()
 
 getMethod ()
 
 getNamespace ()
 
 getRecordFactory ()
 
 isEnabledFor ($level)
 
 log ($level, $msg, array $args=array(),\Exception $exception=null)
 
 setFilters (\Plop\FiltersCollectionAbstract $filters)
 
 setHandlers (\Plop\HandlersCollectionAbstract $handlers)
 
 setLevel ($level)
 
 setRecordFactory (\Plop\RecordFactoryInterface $factory)
 
- Public Member Functions inherited from Plop\LoggerAbstract
 alert ($msg, array $args=array(),\Exception $exception=null)
 
 critical ($msg, array $args=array(),\Exception $exception=null)
 
 debug ($msg, array $args=array(),\Exception $exception=null)
 
 emergency ($msg, array $args=array(),\Exception $exception=null)
 
 error ($msg, array $args=array(),\Exception $exception=null)
 
 exception ($msg,\Exception $exception, array $args=array())
 
 info ($msg, array $args=array(),\Exception $exception=null)
 
 notice ($msg, array $args=array(),\Exception $exception=null)
 
 warn ($msg, array $args=array(),\Exception $exception=null)
 
 warning ($msg, array $args=array(),\Exception $exception=null)
 

Protected Member Functions

 callHandlers (\Plop\RecordInterface $record)
 
 getStderr ()
 
 handle (\Plop\RecordInterface $record)
 

Protected Attributes

 $cls
 Name of the class this logger relates to.
 
 $emittedWarning
 Whether a warning has been emitted about this logger having no handlers.
 
 $filters
 An object handling a collection of filters.
 
 $handlers
 A collection of handlers currently associated with this logger.
 
 $level
 Minimum level at which this logger will accept log entries.
 
 $method
 Name of the method or function this logger relates to.
 
 $ns
 Name of the namespace this logger relates to.
 

Detailed Description

A class that provides logging capabilities.

Definition at line 27 of file Logger.php.

Constructor & Destructor Documentation

Plop\Logger::__construct (   $ns = null,
  $cls = null,
  $method = null,
\Plop\HandlersCollectionAbstract  $handlers = null,
\Plop\FiltersCollectionAbstract  $filters = null 
)

Construct a new logger with no attached handlers and that accepts any log entry.

Parameters
string | null$ns(optional) The name of the namespace this logger relates to. The default is null (meaning this logger is related to the global namespace).
string | null$cls(optional) The name of the class this logger relates to. The default is null (meaning this logger is not related to any specific class).
string | null$method(optional) The name of the method or function this logger relates to. The default is null (meaning this logger is not related to any specific method or function).
Plop::HandlersCollectionAbstract$handlers(optional) A collection of handlers to associate with this logger. Defaults to an empty list.
Plop::FiltersCollectionAbstract$filters(optional) A collection of filters to associate with this logger. Defaults to an empty list.

Definition at line 79 of file Logger.php.

Member Function Documentation

Plop\Logger::callHandlers ( \Plop\RecordInterface  $record)
protected

Call every handler associated with this logger in turn, passing them a log record to handle.

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

Definition at line 232 of file Logger.php.

Plop\Logger::getClass ( )

Return the name of the class this logger applies to.

Return values
stringName of the class this logger relates to.
See also
Plop::LoggerInterface::getNamespace() and Plop::LoggerInterface::getMethod().

Implements Plop\LoggerInterface.

Definition at line 127 of file Logger.php.

Plop\Logger::getFilters ( )

Get the collection of filters currently associated with this logger.

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

Implements Plop\LoggerInterface.

Definition at line 152 of file Logger.php.

Plop\Logger::getHandlers ( )

Get the collection of handlers currently associated with this logger.

Return values
Plop::HandlersCollectionAbstractCollection of handlers associated with this logger.

Implements Plop\LoggerInterface.

Definition at line 165 of file Logger.php.

Plop\Logger::getLevel ( )

Return the minimum level a log record must have to be handled by this class.

Return values
intMinimum level at which log records will be accepted.

Implements Plop\LoggerInterface.

Definition at line 269 of file Logger.php.

Plop\Logger::getMethod ( )

Return the name of the method or function this logger applies to.

Return values
stringName of the method/function this logger relates to.
See also
Plop::LoggerInterface::getNamespace() and Plop::LoggerInterface::getClass().

Implements Plop\LoggerInterface.

Definition at line 133 of file Logger.php.

Plop\Logger::getNamespace ( )

Return the name of the namespace this logger applies to.

Return values
stringName of the namespace this logger relates to.
See also
Plop::LoggerInterface::getClass() and Plop::LoggerInterface::getMethod().

Implements Plop\LoggerInterface.

Definition at line 121 of file Logger.php.

Plop\Logger::getRecordFactory ( )

Return the factory used to produce log records.

Return values
Plop::RecordFactoryInterfaceThe factory used to produce records.

Implements Plop\LoggerInterface.

Definition at line 139 of file Logger.php.

Plop\Logger::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 263 of file Logger.php.

Plop\Logger::handle ( \Plop\RecordInterface  $record)
protected

Handle a log record.

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

Definition at line 214 of file Logger.php.

Plop\Logger::isEnabledFor (   $level)

Implements Plop\LoggerInterface.

Definition at line 286 of file Logger.php.

References Plop\Plop\getInstance().

Plop\Logger::log (   $level,
  $msg,
array  $args = array(),
\Exception  $exception = null 
)

Implements Plop\LoggerInterface.

Definition at line 178 of file Logger.php.

References Plop\Plop\findCaller().

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

Implements Plop\LoggerInterface.

Definition at line 158 of file Logger.php.

Plop\Logger::setHandlers ( \Plop\HandlersCollectionAbstract  $handlers)

Implements Plop\LoggerInterface.

Definition at line 171 of file Logger.php.

Plop\Logger::setLevel (   $level)

Implements Plop\LoggerInterface.

Definition at line 275 of file Logger.php.

References Plop\Plop\getInstance().

Plop\Logger::setRecordFactory ( \Plop\RecordFactoryInterface  $factory)

Implements Plop\LoggerInterface.

Definition at line 145 of file Logger.php.


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