Class Debug
Supports debugging and core error handling.
Attaches custom methods to the default error handling hooks in PHP. Currently, two levels of error are supported:
- Notice
- Warning
- Error
Uncaught exceptions are currently passed to the debug reporter as standard PHP errors.
Errors handled by this class are passed along to SS_Log. For
configuration information, see the SS_Log class documentation.
Methods summary
public static
|
|
public static
|
|
public static
|
|
public static
unknown
|
|
public static
|
|
public static
|
|
public static
|
|
public static
|
#
loadErrorHandlers( )
Load error handlers into environment. Caution: The error levels default to E_ALL is the site is in dev-mode (set in main.php). |
public static
|
|
public static
|
#
warningHandler( unknown_type $errno, unknown_type $errstr, unknown_type $errfile, unknown_type $errline, unknown_type $errcontext )
Handle a non-fatal warning error thrown by PHP interpreter. |
public static
|
#
fatalHandler( unknown_type $errno, unknown_type $errstr, unknown_type $errfile, unknown_type $errline, unknown_type $errcontext )
Handle a fatal error, depending on the mode of the site (ie: Dev, Test, or Live). |
public static
string
|
#
friendlyError( integer $statusCode = 500, string $friendlyErrorMessage = null, string $friendlyErrorDetail = null )
Render a user-facing error page, using the default HTML error template
rendered by |
public static
|
|
public static
|
|
public static
|
|
public static
boolean
|
#
emailError( string $emailAddress, string $errno, string $errstr, string $errfile, integer $errline, string $errcontext, string $errorType = "Error" )
Dispatch an email notification message when an error is triggered. |
protected static
|
#
log_error_if_necessary( mixed $errno, mixed $errstr, mixed $errfile, mixed $errline, mixed $errcontext, mixed $errtype )
Log the given error, if self::$log_errors is set. Uses the native error_log() funtion in PHP. |
public static
|
|
public static
string
|
|
public static
|
#
send_errors_to( string $emailAddress, string $sendWarnings = false )
Send errors to the given email address. Can be used like so: if(Director::isLive()) Debug::send_errors_to("sam@silverstripe.com"); |
public static
string
|
|
public static
|
|
public static
string
|
|
public static
|
|
public static
|
|
public static
|
|
public static
|
|
public static
|
#
require_developer_login( )
Check if the user has permissions to run URL debug tools, else redirect them to log in. |
Magic methods summary
Properties summary
protected static
string
|
$custom_smtp_server |
#
string Custom mailserver for sending mails. |
protected static
mixed
|
$send_errors_to |
#
string Email address to send error notifications |
protected static
mixed
|
$send_warnings_to |
#
string Email address to send warning notifications |
protected static
mixed
|
$log_errors_to |
#
String indicating the file where errors are logged. Filename is relative to the site root. The named file will have a terse log sent to it, and the full log (an encoded file containing backtraces and things) will go to a file of a similar name, but with the suffix ".full" added. |
public static
string
|
$friendly_error_header |
#
The header of the message shown to users on the live site when a fatal error occurs. |
public static
string
|
$friendly_error_detail |
#
The body of the message shown to users on the live site when a fatal error occurs. |
public static
integer
|
$headerCount |