1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-10-22 00:56:08 +02:00

made change BC

This commit is contained in:
Johannes M. Schmitt
2012-03-21 20:16:42 -06:00
parent 8cdc9c6e10
commit 8ee130dd24
2 changed files with 13 additions and 10 deletions

View File

@@ -12,9 +12,7 @@
namespace Monolog\Handler; namespace Monolog\Handler;
use Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy; use Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy;
use Monolog\Handler\FingersCrossed\ActivationStrategyInterface; use Monolog\Handler\FingersCrossed\ActivationStrategyInterface;
use Monolog\Logger; use Monolog\Logger;
/** /**
@@ -37,15 +35,22 @@ class FingersCrossedHandler extends AbstractHandler
/** /**
* @param callback|HandlerInterface $handler Handler or factory callback($record, $fingersCrossedHandler). * @param callback|HandlerInterface $handler Handler or factory callback($record, $fingersCrossedHandler).
* @param ActivationStrategyInterface $activationStrategy Strategy which determines when this handler takes action * @param int|ActivationStrategyInterface $activationStrategy Strategy which determines when this handler takes action
* @param int $bufferSize How many entries should be buffered at most, beyond that the oldest items are removed from the buffer. * @param int $bufferSize How many entries should be buffered at most, beyond that the oldest items are removed from the buffer.
* @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not
* @param Boolean $stopBuffering Whether the handler should stop buffering after being triggered (default true) * @param Boolean $stopBuffering Whether the handler should stop buffering after being triggered (default true)
*/ */
public function __construct($handler, ActivationStrategyInterface $activationStrategy = null, $bufferSize = 0, $bubble = true, $stopBuffering = true) public function __construct($handler, $activationStrategy = null, $bufferSize = 0, $bubble = true, $stopBuffering = true)
{ {
if (null === $activationStrategy) {
$activationStrategy = new ErrorLevelActivationStrategy(Logger::WARNING);
}
if (!$activationStrategy instanceof ActivationStrategyInterface) {
$activationStrategy = new ErrorLevelActivationStrategy($activationStrategy);
}
$this->handler = $handler; $this->handler = $handler;
$this->activationStrategy = $activationStrategy ?: new ErrorLevelActivationStrategy(Logger::WARNING); $this->activationStrategy = $activationStrategy;
$this->bufferSize = $bufferSize; $this->bufferSize = $bufferSize;
$this->bubble = $bubble; $this->bubble = $bubble;
$this->stopBuffering = $stopBuffering; $this->stopBuffering = $stopBuffering;

View File

@@ -11,8 +11,6 @@
namespace Monolog\Handler; namespace Monolog\Handler;
use Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy;
use Monolog\TestCase; use Monolog\TestCase;
use Monolog\Logger; use Monolog\Logger;
@@ -71,7 +69,7 @@ class FingersCrossedHandlerTest extends TestCase
public function testHandleRestartBufferingAfterBeingTriggeredWhenStopBufferingIsDisabled() public function testHandleRestartBufferingAfterBeingTriggeredWhenStopBufferingIsDisabled()
{ {
$test = new TestHandler(); $test = new TestHandler();
$handler = new FingersCrossedHandler($test, new ErrorLevelActivationStrategy(Logger::WARNING), 0, false, false); $handler = new FingersCrossedHandler($test, Logger::WARNING, 0, false, false);
$handler->handle($this->getRecord(Logger::DEBUG)); $handler->handle($this->getRecord(Logger::DEBUG));
$handler->handle($this->getRecord(Logger::WARNING)); $handler->handle($this->getRecord(Logger::WARNING));
$handler->handle($this->getRecord(Logger::INFO)); $handler->handle($this->getRecord(Logger::INFO));
@@ -86,7 +84,7 @@ class FingersCrossedHandlerTest extends TestCase
public function testHandleBufferLimit() public function testHandleBufferLimit()
{ {
$test = new TestHandler(); $test = new TestHandler();
$handler = new FingersCrossedHandler($test, new ErrorLevelActivationStrategy(Logger::WARNING), 2); $handler = new FingersCrossedHandler($test, Logger::WARNING, 2);
$handler->handle($this->getRecord(Logger::DEBUG)); $handler->handle($this->getRecord(Logger::DEBUG));
$handler->handle($this->getRecord(Logger::DEBUG)); $handler->handle($this->getRecord(Logger::DEBUG));
$handler->handle($this->getRecord(Logger::INFO)); $handler->handle($this->getRecord(Logger::INFO));
@@ -132,7 +130,7 @@ class FingersCrossedHandlerTest extends TestCase
public function testIsHandlingAlways() public function testIsHandlingAlways()
{ {
$test = new TestHandler(); $test = new TestHandler();
$handler = new FingersCrossedHandler($test, new ErrorLevelActivationStrategy(Logger::ERROR)); $handler = new FingersCrossedHandler($test, Logger::ERROR);
$this->assertTrue($handler->isHandling($this->getRecord(Logger::DEBUG))); $this->assertTrue($handler->isHandling($this->getRecord(Logger::DEBUG)));
} }
} }