|
Plop
A simple logging library for PHP
|
Inheritance diagram for Plop\Plop:Public Member Functions | |
| __clone () | |
| This class is not clone-safe. | |
| addLevelName ($levelName, $levelValue) | |
| addLogger (\Plop\LoggerInterface $logger) | |
| count () | |
| getCreationDate () | |
| getLevelName ($level) | |
| getLevelValue ($levelName) | |
| getLogger ($namespace= '', $class= '', $method= '') | |
| offsetExists ($offset) | |
| offsetGet ($offset) | |
| offsetSet ($offset, $logger) | |
| offsetUnset ($offset) | |
Public Member Functions inherited from Plop\IndirectLoggerAbstract | |
| 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) | |
Static Public Member Functions | |
| static | findCaller () |
| static & | getInstance () |
Public Attributes | |
| const | BASIC_FORMAT = '[%(levelname)s] %(message)s' |
| Default format used by the root logger. | |
Protected Member Functions | |
| __construct () | |
| getIndirectLogger () | |
Protected Member Functions inherited from Plop\IndirectLoggerAbstract | |
| getIndirectLogger () | |
Static Protected Member Functions | |
| static | getLoggerId (\Plop\LoggerInterface $logger) |
Protected Attributes | |
| $created | |
| Date and time when the logging service was initialized. | |
| $levelNames | |
| Mapping between level names and their value. | |
| $loggers | |
| Associative array of loggers, indexed by their ID. | |
Static Protected Attributes | |
| static | $instance = null |
| Shared instance of the logging service. | |
Main class for Plop.
For the most basic use cases, the Plop class acts as an instance of Plop::LoggerInterface, which means you only need code such as the following to start logging messages:
This is equivalent to the following slightly less concise piece of code:
For more complex use cases, you will need to configure logging (either manually or by means of tools such as a Dependency Injection Container). The following piece of code shows how to configure bits of Plop using PHP code:
|
protected |
| Plop\Plop::addLevelName | ( | $levelName, | |
| $levelValue | |||
| ) |
| Plop\Plop::addLogger | ( | \Plop\LoggerInterface | $logger | ) |
Register a logger.
This is effectively a shortcut for the following piece of code:
It is kept to help other tools that operate on Plop (such as Dependency Injection Containers) but do not support object subscripting (ie. array notation).
| Plop::LoggerInterface | $logger | New logger to register. |
| Plop | The current logging service (ie. $this). |
| Plop\Plop::count | ( | ) |
|
static |
Return information about the caller of this method.
| array | An associative array with information about the caller. This array always contains the following keys:
|
Each of those values may be null (or 0 in the case of "line") if the information could not be extracted from the call stack.
Definition at line 624 of file Plop.php.
Referenced by Plop\Logger\log().
| Plop\Plop::getCreationDate | ( | ) |
|
protected |
Return the actual logger that will be used to proxy calls to methods of the Plop::LoggerInterface interface.
| Plop::LoggerInterface | Actual logger to proxy calls to. |
|
static |
Return an instance of the logging service.
| Plop | Instance of the logging service. |
Definition at line 195 of file Plop.php.
Referenced by Plop\Filter\Level\__construct(), Plop\Record\__construct(), Plop\Logger\isEnabledFor(), Plop\Psr3Logger\log(), and Plop\Logger\setLevel().
| Plop\Plop::getLevelName | ( | $level | ) |
Return the name of a level given its value.
| int | $level | Level for which a name must be returned. |
| string | Name for the given level. |
| Plop\Plop::getLevelValue | ( | $levelName | ) |
Return the value of a level given its name.
| string | $levelName | Level for which a value must be returned. |
| int | Value for the given level. |
Definition at line 283 of file Plop.php.
Referenced by Plop\Filter\Level\__construct().
| Plop\Plop::getLogger | ( | $namespace = '', |
|
$class = '', |
|||
$method = '' |
|||
| ) |
Return the logger that is most appropriate given a bit of context.
| string | $namespace | (optional) Namespace for which a logger must be returned. Most of the time, you will pass the value of __NAMESPACE__ to this parameter. |
| string | $class | (optional) Class for which a logger must be returned. Most of the time, you will pass the value of __CLASS__ to this parameter. |
| string | $method | (optional) Method inside the given class for which a logger must be returned. Most of the time, you will pass the value of __FUNCTION__ to this parameter, even for methods, where this will have the same value as __FUNCTION__. |
| Plop::LoggerInterface | Logger that is the most appropriate given the context. |
|
staticprotected |
Return a logger's identifier.
| Plop::LoggerInterface | $logger | A logger whose identifier we're interested in. |
| string | The logger's identifier. |
| Plop\Plop::offsetExists | ( | $offset | ) |
Return a flag indicating whether a logger with the given identifier was registered with Plop.
| string | Plop::LoggerInterface | $offset | A logger identifier. You may also pass a logger, in which case, that logger's identifier will be used for the test. |
| bool | A flag indicating whether a logger was registered with that identifier (true) or not (false). |
Implements ArrayAccess.
| Plop\Plop::offsetGet | ( | $offset | ) |
Return the registered logger with the given identifier, one of its parents, or the root logger if no other logger can be found.
| string | $offset | Identifier of the logger to return. |
| Plop::LoggerInterface | The registered logger with that identifier if one was found, or the root logger. |
Implements ArrayAccess.
| Plop\Plop::offsetSet | ( | $offset, | |
| $logger | |||
| ) |
Register a new logger with Plop.
| mixed | $offset | (deprecated) Identifier for the logger, must match the identifier of the logger given in $logger. |
| Plop::LoggerInterface | $logger | New logger to register. |
Implements ArrayAccess.
| Plop\Plop::offsetUnset | ( | $offset | ) |
Unregister a logger.
| string | Plop::LoggerInterface | $offset | Identifier of the logger to unregister. You may also pass a logger, in which case, that logger's identifier will be used. |
Implements ArrayAccess.