本文整理匯總了PHP中Symfony\Component\Debug\ErrorHandler::setDefaultLogger方法的典型用法代碼示例。如果您正苦於以下問題:PHP ErrorHandler::setDefaultLogger方法的具體用法?PHP ErrorHandler::setDefaultLogger怎麽用?PHP ErrorHandler::setDefaultLogger使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\Debug\ErrorHandler
的用法示例。
在下文中一共展示了ErrorHandler::setDefaultLogger方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testHandleDeprecation
public function testHandleDeprecation()
{
$that = $this;
$logArgCheck = function ($level, $message, $context) use($that) {
$that->assertEquals(LogLevel::INFO, $level);
$that->assertArrayHasKey('level', $context);
$that->assertEquals(E_RECOVERABLE_ERROR | E_USER_ERROR | E_DEPRECATED | E_USER_DEPRECATED, $context['level']);
$that->assertArrayHasKey('stack', $context);
};
$logger = $this->getMock('Psr\\Log\\LoggerInterface');
$logger->expects($this->once())->method('log')->will($this->returnCallback($logArgCheck));
$handler = new ErrorHandler();
$handler->setDefaultLogger($logger);
@$handler->handleError(E_USER_DEPRECATED, 'Foo deprecation', __FILE__, __LINE__, array());
}
示例2: testHandleDeprecation
public function testHandleDeprecation()
{
$logArgCheck = function ($level, $message, $context) {
$this->assertEquals(LogLevel::INFO, $level);
$this->assertArrayHasKey('exception', $context);
$exception = $context['exception'];
$this->assertInstanceOf(\ErrorException::class, $exception);
$this->assertSame('User Deprecated: Foo deprecation', $exception->getMessage());
};
$logger = $this->getMock('Psr\\Log\\LoggerInterface');
$logger->expects($this->once())->method('log')->will($this->returnCallback($logArgCheck));
$handler = new ErrorHandler();
$handler->setDefaultLogger($logger);
@$handler->handleError(E_USER_DEPRECATED, 'Foo deprecation', __FILE__, __LINE__, array());
}