A simple PSR-3 compliant logger
This library is designed to be used with Composer
Require entry:
{
"myena/default-logger": "@stable"
}
$logger = new \MyENA\DefaultLogger();
$logger->debug('hello!');
The default level of this logger is debug
The default stream for this logger is php://output
You may specify custom levels one of two ways:
Construction:
$logger = new \MyENA\DefaultLogger(\Psr\Log\LogLevel::INFO);
Post-Construction:
$logger->setLogLevel(\Psr\Log\LogLevel::INFO);
If you attempt to specify a level not denoted by \Psr\Log\LogLevel, an exception will be thrown.
If you wish for the log output to go to a file or some other resource writeable by the fwrite function, you may pass it in as the 2nd argument.
$logger = new \MyENA\DefaultLogger(\Psr\Log\LogLevel::DEBUG, fopen('tmp/test.log', 'ab'));
If this file becomes un-writeable for some reason, it will attempt to reconstruct the internal resource. If it is unable, it will revert to using the stream returned by the defaultStream().
NOTE: No write-ability determination is done, if you pass in a read-only stream it will ultimately not work.