1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-05 12:47:39 +02:00

Tweak patch a bit, refs #617

This commit is contained in:
Jordi Boggiano
2015-08-09 18:28:21 +01:00
parent eabe95f9f0
commit 419ca7ac25
2 changed files with 8 additions and 9 deletions

View File

@@ -176,20 +176,19 @@ class Logger implements LoggerInterface
}
/**
* Set handlers, removing all existing ones.
* Falsey values will be ignored, and if a map is passed, keys will be ignored.
* Set handlers, replacing all existing ones.
*
* @param array $handlers All elements must be of type HandlerInterface
* If a map is passed, keys will be ignored.
*
* @param HandlerInterface[] $handlers
* @return $this
*/
public function setHandlers(array $handlers)
{
$this->handlers = array();
foreach ($handlers as $handler) {
if ($handler) {
foreach (array_reverse($handlers) as $handler) {
$this->pushHandler($handler);
}
}
return $this;
}

View File

@@ -156,11 +156,11 @@ class LoggerTest extends \PHPUnit_Framework_TestCase
$logger->setHandlers(array(
"AMapKey" => $handler1,
"Falsey" => null,
"Woop" => $handler2,
));
// Keys have been scrubbed
$this->assertEquals(array($handler1), $logger->getHandlers());
$this->assertEquals(array($handler1, $handler2), $logger->getHandlers());
}
/**