joomla / joomla-framework

[READ-ONLY] This repo is no longer in active development. Please see https://github.com/joomla-framework for the individual Framework packages.
http://framework.joomla.org
GNU General Public License v2.0
189 stars 140 forks source link

RFC: NullLogger #262

Closed dongilbert closed 11 years ago

dongilbert commented 11 years ago

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.

eddieajau commented 11 years ago

:+1:

mbabker commented 11 years ago

:+1:

dongilbert commented 11 years ago

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.

piotr-cz commented 11 years ago

:+1:

elkuku commented 11 years ago

:+1: