Public Member Functions | Protected Member Functions | Protected Attributes

Robo47_ErrorHandler Class Reference

List of all members.

Public Member Functions

 __construct ($log=null, $category= 'errorHandler')
 getErrorPriorityMapping ()
 Get error priority Mapping.
 getLog ()
 Get Log.
 getLogCategory ()
 Get Log Category.
 getOldErrorHandler ()
 Get old ErrorHandler.
 handleError ($errno, $errstr, $errfile, $errline)
 Handle Error.
 registerAsErrorHandler ()
 Register ErrorHandler.
 setErrorPriorityMapping (array $errorPriorityMapping)
 Set error priority Mapping.
 setLog (Zend_Log $log=null)
 Set Log.
 setLogCategory ($category)
 Set Log Category.
 unregisterAsErrorHandler ()
 Unregister ErrorHandler.

Protected Member Functions

 _getErrorsPriority ($error)
 Get error priority Mapping.
 _logError ($errno, $errstr, $errfile, $errline)
 Log error.

Protected Attributes

 $_errorPriorityMapping
 $_isErrorHandler = false
 $_log = null
 $_logCategory = 'errorHandler'
 $_oldErrorHandler = null

Detailed Description

Definition at line 31 of file ErrorHandler.php.


Constructor & Destructor Documentation

Robo47_ErrorHandler::__construct ( log = null,
category = 'errorHandler' 
)
Parameters:
Zend_Log $log
string $category

Definition at line 80 of file ErrorHandler.php.

References setLog(), and setLogCategory().

    {
        $this->setLog($log);
        $this->setLogCategory($category);
    }

Here is the call graph for this function:


Member Function Documentation

Robo47_ErrorHandler::_getErrorsPriority ( error  )  [protected]

Get error priority Mapping.

Parameters:
integer $error
Returns:
integer

Definition at line 136 of file ErrorHandler.php.

Referenced by _logError().

    {
        if (isset($this->_errorPriorityMapping[$error])) {
            return $this->_errorPriorityMapping[$error];
        } else {
            return $this->_errorPriorityMapping['unknown'];
        }
    }

Here is the caller graph for this function:

Robo47_ErrorHandler::_logError ( errno,
errstr,
errfile,
errline 
) [protected]

Log error.

Parameters:
integer $errno
string $errstr
string $errfile
integer $errline

Definition at line 178 of file ErrorHandler.php.

References _getErrorsPriority(), getLog(), and getLogCategory().

Referenced by handleError().

    {
        if (null !== $this->getLog()) {
            $priority = $this->_getErrorsPriority($errno);
            $message = $errstr . ' in ' . $errfile . ':' . $errline;
            $category = array('category' => $this->getLogCategory());
            $this->getLog()->log($message, $priority, $category);
        }
        $displayErrors = ini_get('display_errors');
        ini_set('display_errors', 'Off');
        if (ini_get('log_errors')) {
            $path = ini_get('error_log');
            if (is_writeable(dirname($path))) {
                $message = sprintf(
                    "PHP %s:  %s in %s on line %d",
                    $errno,
                    $errstr,
                    $errfile,
                    $errline
                );
                error_log($message, 0);
            }
        }
        ini_set('display_errors', $displayErrors);
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Robo47_ErrorHandler::getErrorPriorityMapping (  ) 

Get error priority Mapping.

Returns:
array

Definition at line 165 of file ErrorHandler.php.

    {
        return $this->_errorPriorityMapping;
    }

Robo47_ErrorHandler::getLog (  ) 

Get Log.

Returns:
Zend_Log

Definition at line 103 of file ErrorHandler.php.

Referenced by _logError().

    {
        return $this->_log;
    }

Here is the caller graph for this function:

Robo47_ErrorHandler::getLogCategory (  ) 

Get Log Category.

Returns:
string

Definition at line 125 of file ErrorHandler.php.

Referenced by _logError().

    {
        return $this->_logCategory;
    }

Here is the caller graph for this function:

Robo47_ErrorHandler::getOldErrorHandler (  ) 

Get old ErrorHandler.

Returns:
callback

Definition at line 223 of file ErrorHandler.php.

    {
        return $this->_oldErrorHandler;
    }

Robo47_ErrorHandler::handleError ( errno,
errstr,
errfile,
errline 
)

Handle Error.

Parameters:
integer $errno
string $errstr
string $errfile
integer $errline

Definition at line 250 of file ErrorHandler.php.

References _logError().

    {
        // suppress errors using @
        if (error_reporting() == 0) {
            return;
        }
        $this->_logError($errno, $errstr, $errfile, $errline);
        throw new Robo47_ErrorException($errstr, 0, $errno, $errfile, $errline);
    }

Here is the call graph for this function:

Robo47_ErrorHandler::registerAsErrorHandler (  ) 

Register ErrorHandler.

Returns:
Robo47_ErrorHandler *Provides Fluent Interface*

Definition at line 209 of file ErrorHandler.php.

    {
        $handler = array($this, 'handleError');
        $errorLevel = E_ALL | E_STRICT;
        $this->_oldErrorHandler = set_error_handler($handler, $errorLevel);
        $this->_isErrorHandler = true;
        return $this;
    }

Robo47_ErrorHandler::setErrorPriorityMapping ( array $  errorPriorityMapping  ) 

Set error priority Mapping.

Parameters:
array $errorPriorityMapping
Returns:
Robo47_ErrorHandler *Provides Fluent Interface*

Definition at line 151 of file ErrorHandler.php.

    {
        $this->_errorPriorityMapping = $errorPriorityMapping;
        if (!isset($this->_errorPriorityMapping['unknown'])) {
            $this->_errorPriorityMapping['unknown'] = 0;
        }
        return $this;
    }

Robo47_ErrorHandler::setLog ( Zend_Log $  log = null  ) 

Set Log.

Parameters:
Zend_Log $log
Returns:
Robo47_ErrorHandler *Provides Fluent Interface*

Definition at line 92 of file ErrorHandler.php.

Referenced by __construct().

    {
        $this->_log = $log;
        return $this;
    }

Here is the caller graph for this function:

Robo47_ErrorHandler::setLogCategory ( category  ) 

Set Log Category.

Parameters:
string $category
Returns:
Robo47_ErrorHandler *Provides Fluent Interface*

Definition at line 114 of file ErrorHandler.php.

Referenced by __construct().

    {
        $this->_logCategory = $category;
        return $this;
    }

Here is the caller graph for this function:

Robo47_ErrorHandler::unregisterAsErrorHandler (  ) 

Unregister ErrorHandler.

Returns:
Robo47_ErrorHandler *Provides Fluent Interface*

Definition at line 233 of file ErrorHandler.php.

    {
        if ($this->_isErrorHandler) {
            set_error_handler($this->_oldErrorHandler);
            $this->_isErrorHandler = false;
        }
        return $this;
    }


Member Data Documentation

Robo47_ErrorHandler::$_errorPriorityMapping [protected]
Initial value:
 array(
        E_ERROR => 3, 
        E_WARNING => 4, 
        E_NOTICE => 5, 
        E_USER_ERROR => 3, 
        E_USER_WARNING => 4, 
        E_USER_NOTICE => 5, 
        E_CORE_ERROR => 3, 
        E_CORE_WARNING => 4, 
        E_STRICT => 3, 
        E_RECOVERABLE_ERROR => 3, 
        'unknown' => 0, 

    )

Definition at line 61 of file ErrorHandler.php.

Robo47_ErrorHandler::$_isErrorHandler = false [protected]

Definition at line 43 of file ErrorHandler.php.

Robo47_ErrorHandler::$_log = null [protected]

Definition at line 49 of file ErrorHandler.php.

Robo47_ErrorHandler::$_logCategory = 'errorHandler' [protected]

Definition at line 55 of file ErrorHandler.php.

Robo47_ErrorHandler::$_oldErrorHandler = null [protected]

Definition at line 38 of file ErrorHandler.php.


The documentation for this class was generated from the following file: