dev-master
9999999-devStdout your logs directly!
MIT
The Requires
- php >=5.5.9
- psr/log ^1.0
by Yoann RENARD
Wallogit.com
2017 © Pedro Peláez
Stdout your logs directly!
Stdout your logs directly!, (*1)
Use Composer and run :, (*2)
$> composer require yoannrenard/inline-logger
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., (*3)
But imagine you wanna, for some reason, play with it in a dummy command line, without Monolog, without anything J, (*4)
$randomClass = new RandomClass(new InlineLogger()); $randomClass->randomMethod();
This dummy InlineLogger class will print in your stdout all your beloved logs, (*5)
[2017-02-13 16:07:30] php.INFO: My random log
Stdout your logs directly!
MIT