Exemplo n.º 1
0
 /**
  * @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);
 }
Exemplo n.º 2
0
 /**
  * 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;
 }