ErrorHandler that complies with PHP's set_error_handler() function. The error handler is configured through an array that you have to pass to the handler's constructor, containing one or more key-value pairs representing the configuration parameters.
| Parameter | Mandatory | Value(s) | Default value |
|---|---|---|---|
| _DISPLAY_LEVEL | No | See below | E_NONE |
|
Bitmap identifying the types of errors the error handler will display on the web client. Value can be set in a similar way as with PHP's error_reporting function or ini file setting.
Several additional constants are available for your conveniance:
|
|||
| _DISPLAY_FORMAT | No | String | See below |
String with the formatting rule for errors to be displayed on the client. Use the following identifiers to identify certain fields:
Defaults to ' |
|||
| _LOGGING_LEVEL | No | See below | E_NONE |
| Bitmap identifying the types of errors for which the error handler will log error information in a log file. See _DISPLAY_LEVEL for information on how to set this level. | |||
| _LOGGING_FORMAT | No | String | See below |
|
String with the formatting rule for errors to be logged in a log file. See _DISPLAY_FORMAT for formatting options.
Defaults to ' |
|||
| _LOGGING_MECHANISM | Conditionally | 1 | 2 | 1 |
Indicates the mechanism that the error handler will use to log error information:
Mandatory if the logging level is other than E_NONE, will be ignored otherwise. |
|||
| _LOGFILE_URI | Conditionally | String | See below |
|
URI of the log file to be used if the logging mechanism is set to '2'.
Mandatory if logging mechanism is 2, will be ignored otherwise. |
|||
| _ALERT_LEVEL | No | See below | E_NONE |
| Bitmap identifying the types of errors for which the error handler will generate an alert email. See _DISPLAY_LEVEL for information on how to set this level. | |||
| _ALERT_EMAIL_ADDRESSES | Conditionally | String | |
|
Email address or list of email adresses separated by commas to which alert emails will be sent.
Mandatory if the alert level is other than E_NONE, will be ignored otherwise. |
|||
| _ALERT_SUBJECT_FORMAT | No | String | See below |
|
String with the formatting rule for the subject line of an alert email. See _DISPLAY_FORMAT for formatting options.
Defaults to ' |
|||
| _ALERT_BODY_FORMAT | No | String | See below |
|
String with the formatting rule for the body of an alert email. See _DISPLAY_FORMAT for formatting options.
Defaults to ' |
|||
| _BACKTRACE_LEVEL | No | See below | E_NONE |
|
Bitmap identifying the types of errors for which the error handler will generate a backtrace through PHP's debug_backtrace() function. See _DISPLAY_LEVEL for information on how to set this level.
Note that the backtrace will only be shown, logged or included in the alert email if you have included the %b identifier in the involved format string. |
|||
$containerConfig = array(
// Error handler configuration (uses Phrame's
// standard ErrorHandler)
_ERROR_HANDLER => array(
_INIT_PARAMS => array(
_DISPLAY_LEVEL => E_NONE
,_LOGGING_LEVEL => E_ERRORS | E_WARNINGS
,_LOGGING_MECHANISM => 2
,_LOGFILE_URI =>
'my/path/to/phrame-3-demo.log'
,_ALERT_LEVEL => E_ERRORS
,_ALERT_SUBJECT_FORMAT =>
'Alert from example.com'
,_ALERT_BODY_FORMAT =>
"The following %e occured on %d1:\n\n
Message: %m\n
Script: %f\n
Line: %l\n
Backtrace:\n\n
%b"
,_ALERT_EMAIL_ADDRESSES =>
'[email protected], [email protected]'
,_BACKTRACE_LEVEL => E_ERRORS
)
)
..
other container configuration parameters go here
..
);
?>