PSR-3 (the logging interface) comes prepackaged with a NullLogger that allows us to reduce a lot of our checking code around the usage of a logger. Currently (although inconsistent) most places use something like this:
if ($this->hasLogger())
{
$this->getLogger()->log('some message');
}
Using a NullLogger, we can reduce this to a single line:
$this->getLogger()->log('some message');
The getLogger method has been modified to return a NullLogger if $this->logger is not set or if it's not an instanceof Psr\Log\LoggerInterface.
Being that this is an RFC, I wanted to get some feedback on it before implementing it everywhere else we use a logger. Please :+1: or :-1: your opinion on the matter and whether or not you think we should use this approach.
Looks like we're just implementing PSR-3 in Application, Image and Database. The database implementation is sufficient, IMO, so this PR is ready after updating Application and Image.
PSR-3 (the logging interface) comes prepackaged with a
NullLogger
that allows us to reduce a lot of our checking code around the usage of a logger. Currently (although inconsistent) most places use something like this:Using a
NullLogger
, we can reduce this to a single line:The
getLogger
method has been modified to return aNullLogger
if$this->logger
is not set or if it's not aninstanceof Psr\Log\LoggerInterface
.Being that this is an RFC, I wanted to get some feedback on it before implementing it everywhere else we use a logger. Please :+1: or :-1: your opinion on the matter and whether or not you think we should use this approach.