1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-06 13:16:39 +02:00

Add support for custom logging level per exception class, and set ParseError to be CRITICAL

This commit is contained in:
Jordi Boggiano
2016-05-20 20:45:16 +01:00
parent 2a569ff961
commit 6d2cfa63c9
2 changed files with 53 additions and 10 deletions

View File

@@ -28,4 +28,31 @@ class ErrorHandlerTest extends \PHPUnit_Framework_TestCase
$this->assertCount(2, $handler->getRecords());
$this->assertTrue($handler->hasEmergencyRecords());
}
public function testHandleException()
{
$logger = new Logger('test', array($handler = new TestHandler));
$errHandler = new ErrorHandler($logger);
$errHandler->registerExceptionHandler(array('Monolog\CustomTestException' => Logger::ALERT, 'Throwable' => Logger::WARNING), false);
try {
throw new CustomCustomException();
$this->assertCount(1, $handler->getRecords());
$this->assertTrue($handler->hasAlertRecords());
} catch (\Throwable $e) {}
try {
throw new CustomTestException();
$this->assertCount(2, $handler->getRecords());
$this->assertTrue($handler->hasAlertRecords());
} catch (\Throwable $e) {}
try {
throw new RuntimeException();
$this->assertCount(3, $handler->getRecords());
$this->assertTrue($handler->hasWarningRecords());
} catch (\Throwable $e) {}
}
}
class CustomTestException extends \Exception {}
class CustomCustomException extends CustomTestException {}