Bastien Sevajol 0de4e59322 change chmod | 12 anos atrás | |
---|---|---|
.. | ||
doc | 12 anos atrás | |
src/Monolog | 12 anos atrás | |
tests | 12 anos atrás | |
.gitignore | 12 anos atrás | |
CHANGELOG.mdown | 12 anos atrás | |
README.mdown | 12 anos atrás | |
composer.json | 12 anos atrás | |
phpunit.xml.dist | 12 anos atrás |
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
// create a log channel
$log = new Logger('name');
$log->pushHandler(new StreamHandler('path/to/your.log', Logger::WARNING));
// add records to the log
$log->addWarning('Foo');
$log->addError('Bar');
Every Logger instance has a channel (name) and a stack of handlers. Whenever you add a record to the logger, it traverses the handler stack. Each handler decides whether it handled fully the record, and if so, the propagation of the record ends there.
This allow for flexible logging setups, for example having a FileHandler at the bottom of the stack that will log anything to disk, and on top of that add a MailHandler that will send emails only when an error message is logged. Handlers also have a bubbling property which define whether they block the record or not if they handled it. In this example, setting the MailHandler's $bubble argument to true means that all records will propagate to the FileHandler, even the errors that are handled by the MailHandler.
You can create many Loggers, each defining a channel (e.g.: db, request, router, ..) and each of them combining various handlers, which can be shared or not. The channel is reflected in the logs and allows you to easily see or filter records.
Each Handler also has a Formatter, a default one with settings that make sense will be created if you don't set one. The formatters normalize and format incoming records so that they can be used by the handlers to output useful information.
Custom severity levels are not available. Only six levels (debug, info, warning, error, critical, alert) are present for basic filtering purposes, but for sorting and other use cases that would require flexibility, you should add Processors to the Logger that can add extra information (tags, user ip, ..) to the records before they are handled.
See the doc/ directory for more detailed documentation. The following is only a list of all parts that come with Monolog.
console
messages within FireBug.Bugs and feature request are tracked on GitHub
Jordi Boggiano - j.boggiano@seld.be - http://twitter.com/seldaek
See also the list of contributors which participated in this project.
Monolog is licensed under the MIT License - see the LICENSE file for details
This library is heavily inspired by Python's Logbook library, although most concepts have been adjusted to fit to the PHP world.