netpromotion / lazy-logger
Psr\Log\LoggerInterface implementation which creates real logger only if it is needed
v1.0.0
2019-04-11 08:55 UTC
Requires
- php: >=5.6
- psr/log: ^1.1
Requires (Dev)
- phpunit/phpunit: ^7.5
This package is auto-updated.
Last update: 2026-02-11 23:49:46 UTC
README
Psr\Log\LoggerInterface implementation which creates real logger only if it is needed.
Ideal for entry points which needs to be quick, but should use robust logger like Monolog for error logging.
<?php // entry-point.php $logger = new Netpromotion\LazyLogger\LazyLogger(function () { return Symfony::getInstance()->getContainer()->get('logger'); }); try { doSomething(); exit(0); } catch (Exception $e) { $logger->error('Something went wrong.', [ 'message' => $e->getMessage(), ]); exit(-1); }