yoannrenard / inline-logger
Stdout your logs directly!
1.0.0
2017-02-13 15:24 UTC
Requires
- php: >=5.5.9
- psr/log: ^1.0
This package is auto-updated.
Last update: 2025-01-10 04:06:57 UTC
README
Stdout your logs directly!
Installation
Use Composer and run :
$> composer require yoannrenard/inline-logger
Requirements
- Composer
- PHP >=5.5.9
Example
use Psr\Log\LoggerInterface; use Psr\Log\NullLogger; class RandomClass { /** @var LoggerInterface */ protected $logger; /** * @param LoggerInterface $logger */ public function __construct(LoggerInterface $logger = null) { $this->logger = $logger ?: new NullLogger(); } public function randomMethod() { $this->logger->info('My random log'); } }
A proper LoggerInterface should always be injected into the RandomClass class when running in production.
But imagine you wanna, for some reason, play with it in a dummy command line, without Monolog, without anything J
$randomClass = new RandomClass(new InlineLogger()); $randomClass->randomMethod();
This dummy InlineLogger class will print in your stdout all your beloved logs
[2017-02-13 16:07:30] php.INFO: My random log