mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-04 12:17:35 +02:00
Merge pull request #563 from rjkip/feature/psr-3-passthru
Allow PSR-3 passthru level in FingersCrossedHandler
This commit is contained in:
@@ -61,7 +61,10 @@ class FingersCrossedHandler extends AbstractHandler
|
|||||||
$this->bufferSize = $bufferSize;
|
$this->bufferSize = $bufferSize;
|
||||||
$this->bubble = $bubble;
|
$this->bubble = $bubble;
|
||||||
$this->stopBuffering = $stopBuffering;
|
$this->stopBuffering = $stopBuffering;
|
||||||
$this->passthruLevel = $passthruLevel;
|
|
||||||
|
if ($passthruLevel !== null) {
|
||||||
|
$this->passthruLevel = Logger::toMonologLevel($passthruLevel);
|
||||||
|
}
|
||||||
|
|
||||||
if (!$this->handler instanceof HandlerInterface && !is_callable($this->handler)) {
|
if (!$this->handler instanceof HandlerInterface && !is_callable($this->handler)) {
|
||||||
throw new \RuntimeException("The given handler (".json_encode($this->handler).") is not a callable nor a Monolog\Handler\HandlerInterface object");
|
throw new \RuntimeException("The given handler (".json_encode($this->handler).") is not a callable nor a Monolog\Handler\HandlerInterface object");
|
||||||
|
@@ -15,6 +15,7 @@ use Monolog\TestCase;
|
|||||||
use Monolog\Logger;
|
use Monolog\Logger;
|
||||||
use Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy;
|
use Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy;
|
||||||
use Monolog\Handler\FingersCrossed\ChannelLevelActivationStrategy;
|
use Monolog\Handler\FingersCrossed\ChannelLevelActivationStrategy;
|
||||||
|
use Psr\Log\LogLevel;
|
||||||
|
|
||||||
class FingersCrossedHandlerTest extends TestCase
|
class FingersCrossedHandlerTest extends TestCase
|
||||||
{
|
{
|
||||||
@@ -237,4 +238,18 @@ class FingersCrossedHandlerTest extends TestCase
|
|||||||
$this->assertFalse($test->hasDebugRecords());
|
$this->assertFalse($test->hasDebugRecords());
|
||||||
$this->assertTrue($test->hasInfoRecords());
|
$this->assertTrue($test->hasInfoRecords());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Monolog\Handler\FingersCrossedHandler::close
|
||||||
|
*/
|
||||||
|
public function testPsrLevelPassthruOnClose()
|
||||||
|
{
|
||||||
|
$test = new TestHandler();
|
||||||
|
$handler = new FingersCrossedHandler($test, new ErrorLevelActivationStrategy(Logger::WARNING), 0, true, true, LogLevel::INFO);
|
||||||
|
$handler->handle($this->getRecord(Logger::DEBUG));
|
||||||
|
$handler->handle($this->getRecord(Logger::INFO));
|
||||||
|
$handler->close();
|
||||||
|
$this->assertFalse($test->hasDebugRecords());
|
||||||
|
$this->assertTrue($test->hasInfoRecords());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user