juhara / zzzlogger
PSR-3 LoggerInterface implementation collection
v1.0.1
2018-08-26 04:53 UTC
Requires
- php: >=5.3
- psr/log: ^1.0
Requires (Dev)
- phpunit/phpunit: ^5.0
This package is not auto-updated.
Last update: 2024-10-27 06:23:40 UTC
README
Collection of PSR-3 LoggerInterface implementation.
Requirement
Installation
Run through composer
$ composer require juhara/zzzlogger
Available LoggerInterface implementation
TeeLogger
LoggerInterface implementation that duplicate log to two other loggers.ManyLogger
LoggerInterface implementation that duplicate log to many loggers.
How to use
TeeLogger class
Combine two different loggers as one logger. For example using Monolog to log to file and PHP Debug bar to log to html page.
<?php
$monolog = new Monolog\Logger\Logger();
$debugbar = new \DebugBar\StandardDebugBar();
...
$teeLogger = new \Juhara\ZzzLogger\TeeLogger($monolog, $debugbar['messages']);
$teeLogger->info('hello world');
$teeLogger->warning('world climate change warning');
Daisy chain loggers to combine more than two loggers as one logger.
<?php
$teeLogger1 = new \Juhara\ZzzLogger\TeeLogger($logger1, $logger2);
$teeLogger = new \Juhara\ZzzLogger\TeeLogger($teeLogger1, $logger3);
$teeLogger->info('hello world');
$teeLogger->warning('world climate change warning');
ManyLogger class
Combine many loggers as one logger.
<?php
$manyLogger = new \Juhara\ZzzLogger\ManyLogger([$logger1, $logger2, $logger3]);
$manyLogger->info('hello world');
$manyLogger->warning('world climate change warning');
Contributing
If you have any improvement or issues please submit PR.
Thank you.