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:
@@ -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 {}
|
||||
|
Reference in New Issue
Block a user