123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- <?php
- class Airtime_Zend_Log extends Zend_Log
- {
-
-
- protected $_registeredErrorHandler = false;
-
-
- protected $_errorHandlerMap = false;
-
-
- protected $_origErrorHandler = null;
-
-
- public function __construct(Zend_Log_Writer_Abstract $writer = null)
- {
- parent::__construct($writer);
- }
-
-
- public function errorHandler($errno, $errstr, $errfile, $errline, $errcontext)
- {
- $errorLevel = error_reporting();
- if ($errorLevel && $errno) {
- if (isset($this->_errorHandlerMap[$errno])) {
- $priority = $this->_errorHandlerMap[$errno];
- } else {
- $priority = Zend_Log::INFO;
- }
- $this->log($errstr, $priority, array('errno'=>$errno, 'file'=>$errfile, 'line'=>$errline, 'context'=>$errcontext));
- }
- if ($this->_origErrorHandler !== null) {
- return call_user_func($this->_origErrorHandler, $errno, $errstr, $errfile, $errline, $errcontext);
- }
- return false;
- }
-
-
- public function registerErrorHandler()
- {
-
- if ($this->_registeredErrorHandler) {
- return $this;
- }
- $this->_origErrorHandler = set_error_handler(array($this, 'errorHandler'));
-
-
- $this->_errorHandlerMap = array(
- E_NOTICE => Zend_Log::NOTICE,
- E_USER_NOTICE => Zend_Log::NOTICE,
- E_WARNING => Zend_Log::WARN,
- E_CORE_WARNING => Zend_Log::WARN,
- E_USER_WARNING => Zend_Log::WARN,
- E_ERROR => Zend_Log::ERR,
- E_USER_ERROR => Zend_Log::ERR,
- E_CORE_ERROR => Zend_Log::ERR,
- E_RECOVERABLE_ERROR => Zend_Log::ERR,
- E_STRICT => Zend_Log::DEBUG,
- );
-
- if (defined('E_DEPRECATED')) {
- $this->_errorHandlerMap['E_DEPRECATED'] = Zend_Log::DEBUG;
- }
- if (defined('E_USER_DEPRECATED')) {
- $this->_errorHandlerMap['E_USER_DEPRECATED'] = Zend_Log::DEBUG;
- }
- $this->_registeredErrorHandler = true;
- return $this;
- }
- }
|