本文整理汇总了PHP中Zend_Log::registerErrorHandler方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Log::registerErrorHandler方法的具体用法?PHP Zend_Log::registerErrorHandler怎么用?PHP Zend_Log::registerErrorHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Log
的用法示例。
在下文中一共展示了Zend_Log::registerErrorHandler方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testUsingWithErrorHandler
/**
* @group ZF-9192
*/
public function testUsingWithErrorHandler()
{
$writer = new Zend_Log_Writer_Mock();
$logger = new Zend_Log();
$logger->addWriter($writer);
$this->errWriter = $writer;
$oldErrorLevel = error_reporting();
$this->expectingLogging = true;
error_reporting(E_ALL | E_STRICT);
$oldHandler = set_error_handler(array($this, 'verifyHandlerData'));
$logger->registerErrorHandler();
trigger_error("Testing notice shows up in logs", E_USER_NOTICE);
trigger_error("Testing warning shows up in logs", E_USER_WARNING);
trigger_error("Testing error shows up in logs", E_USER_ERROR);
$this->expectingLogging = false;
error_reporting(0);
trigger_error("Testing notice misses logs", E_USER_NOTICE);
trigger_error("Testing warning misses logs", E_USER_WARNING);
trigger_error("Testing error misses logs", E_USER_ERROR);
restore_error_handler();
// Pop off the Logger
restore_error_handler();
// Pop off the verifyHandlerData
error_reporting($oldErrorLevel);
// Restore original reporting level
unset($this->errWriter);
}
示例2: registerErrorHandler
/**
* Register Logging system as an error handler to log php errors
* Register AM_Log::errorHandlerFatal method as shutdown function
* Note: it still calls the original error handler if set_error_handler is able to return it.
*
* Errors will be mapped as:
* E_NOTICE, E_USER_NOTICE => NOTICE
* E_WARNING, E_CORE_WARNING, E_USER_WARNING => WARN
* E_ERROR, E_USER_ERROR, E_CORE_ERROR, E_RECOVERABLE_ERROR => ERR
* E_DEPRECATED, E_STRICT, E_USER_DEPRECATED => DEBUG
* (unknown/other) => INFO
*
* @link http://www.php.net/manual/en/function.set-error-handler.php Custom error handler
* @link http://php.net/manual/en/function.register-tick-function.php
* @see Zend_Log::registerErrorHandler()
*
* @return AM_Log
*/
public function registerErrorHandler()
{
parent::registerErrorHandler();
register_shutdown_function(array($this, 'errorHandlerFatal'));
return $this;
}