Download the PHP package phoole/logger without Composer
On this page you can find all versions of the php package phoole/logger. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download phoole/logger
More information about phoole/logger
Files in phoole/logger
Informations about the package logger
logger
Slim, simple and full compatible PSR-3 Logger library for PHP.
Installation
Install via the composer
utility.
or add the following lines to your composer.json
Usage
Create the logger instance with a channel id,
Concepts
-
A log entry is a message in the form of an object. It solves the problem of 'WHAT TO BE SENT OUT'. It has a message template, and some processors to process its context.
For example,
Entry\MemoryInfo
is a predefined log entry with a message template of{memory_used}M memory used , peak usage is {memory_peak}M
and oneProcessor\MemoryProcessor
processor.Entry\LogEntry
is the log entry prototype used whenever text message is to be loggedTo define your own log entry,
-
Processors are associated with log entry classes. They solve the problem of 'WHAT EXTRA INFO TO SENT OUT'. They will inject information into entries' context. Processors are
callable(LogEntryInterface $entry)
,Processors are attached to log entries either in the entry class definition as follows,
or during the handler attachment
-
Handlers solve the problem of 'WHERE TO SEND MESSAGE'. They take a log entry object and send it to somewhere.
Handlers takes the form of
callable(LogEntryInterface $entry)
as follows,Handlers are added to the
$logger
with specific log level and type of log message they are going to handle (default isLogEntryInterface
). -
Formatters solve the problem of 'HOW MESSAGE WILL BE PRESENTED''. Each handler of the type
Handler\HandlerAbstract
may have formatter specified during its initiation.
APIs
-
See PSR-3 for standard related APIs.
-
__construct(string $channel)
Create the logger with a channel id.
addHandler(string $level, callable $handler, string $entryClass, int $priority = 50): $this
Add one handler to specified channel with the priority.
-
Phoole\Logger\Entry\LogEntry
relatedstatic function addProcessor(callable ...$callables): string
This method will returns called class name.
Testing
Dependencies
-
PHP >= 7.2.0
- phoole/base 1.*