Phrame 3 Documentation Home  |  Features  |  Downloads  |  Contact Documentation > How To Configure The Error Handler
How To...
Install Phrame 3
Configure The Phrame Container
Configure An Action Server
Define A Module Configuration
Trigger The Phrame Container
Trigger An Action Server
Trigger An Action
Use Language Negotiation
Use Session Validation
Use Phrame Tag Libraries
Load Classes Just In Time
 
How To Configure The Error Handler
From Phrame version 3.1 onwards Phrame comes with a built-in 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.

Configuration parameters
Listed below are all possible configuration parameters, with their allowed value(s) and default value, if any. Be aware that Phrame uses constants rather than strings to identify the parameters, which you must use to ensure proper configuration. If you omit a configuration parameter, Phrame will use the default value.
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:

  • E_NONE - Do not display errors
  • E_ERRORS - Same as E_ERROR | E_COMPILE_ERROR | E_CORE_ERROR | E_USER_ERROR
  • E_WARNINGS - Same as E_WARNING | E_COMPILE_WARNING | E_CORE_WARNING | E_USER_WARNING
  • E_NOTICES - Same as E_NOTICE | E_USER_NOTICE | E_STRICT
_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:
  • %b - Backtrace information (if _BACKTRACE level is met)
  • %d1 - System date formatted according to RFC 2822
  • %d2 - System date formatted according to ISO 8601 (only available in PHP 5)
  • %e - Error type
  • %f - Filename of the script causing the error
  • %l - Linenumber causing the error
  • %m - Error text

Defaults to '<p><strong>%e:</strong> %m <strong>in</strong> %f (%l)</p><pre>%b</pre>'.

_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 '[%d1] %e: %m in %f (%l)\n'.

_LOGGING_MECHANISM Conditionally 1 | 2 1
Indicates the mechanism that the error handler will use to log error information:
  • 1 - Log error using PHP's system logger
  • 2 - Append error to the file defined by _LOGFILE_URI

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 'Phrame Error Handler Alert'.

_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 '[%d1] %e: %m in %f (%l)\n\n%b'.

_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.

Configuration example

$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
  ..
);	

?>

© 2005 Pieter A. van Stempvoort. All rights reserved.
Hosted by www.Geocities.ws

1