Removing deprecated Debug functions, use SS_Log and SS_Backtrace instead

This commit is contained in:
Sean Harvey 2012-11-15 11:13:01 +13:00
parent b6870add90
commit 9eca2d676f

View File

@ -447,168 +447,6 @@ class Debug {
}
echo '</pre>';
}
/**
* Dispatch an email notification message when an error is triggered.
* @deprecated 2.5
* To create error logs by email, use this code instead:
* <code>
* $emailWriter = new SS_LogEmailWriter('my@email.com');
* SS_Log::add_writer($emailWriter, SS_Log::ERR);
* </code>
*
* @param string $emailAddress
* @param string $errno
* @param string $errstr
* @param string $errfile
* @param int $errline
* @param string $errcontext
* @param string $errorType "warning" or "error"
* @return boolean
*/
public static function emailError($emailAddress, $errno, $errstr, $errfile, $errline, $errcontext,
$errorType = "Error") {
Deprecation::notice('2.5',
'Use SS_Log instead. See the class documentation in SS_Log.php for more information.');
$priority = ($errorType == 'Error') ? SS_Log::ERR : SS_Log::WARN;
$writer = new SS_LogEmailWriter($emailAddress);
SS_Log::add_writer($writer, $priority);
SS_Log::log(
array(
'errno' => $errno,
'errstr' => $errstr,
'errfile' => $errfile,
'errline' => $errline,
'errcontext' => $errcontext
),
$priority
);
SS_Log::remove_writer($writer);
}
/**
* Log the given error, if self::$log_errors is set.
* Uses the native error_log() funtion in PHP.
*
* Format: [d-M-Y h:i:s] <type> at <file> line <line>: <errormessage> <url>
*
* @todo Detect script path for CLI errors
* @todo Log detailed errors to full file
* @deprecated 2.5 See SS_Log on setting up error file logging
*/
protected static function log_error_if_necessary($errno, $errstr, $errfile, $errline, $errcontext, $errtype) {
Deprecation::notice('2.5',
'Use SS_Log instead. See the class documentation in SS_Log.php for more information.');
$priority = ($errtype == 'Error') ? SS_Log::ERR : SS_Log::WARN;
$writer = new SS_LogFileWriter('../' . self::$log_errors_to);
SS_Log::add_writer($writer, $priority);
SS_Log::log(
array(
'errno' => $errno,
'errstr' => $errstr,
'errfile' => $errfile,
'errline' => $errline,
'errcontext' => $errcontext
),
$priority
);
SS_Log::remove_writer($writer);
}
/**
* @param string $server IP-Address or domain
* @deprecated 2.5 See SS_Log on setting up error email notification
*/
public static function set_custom_smtp_server($server) {
self::$custom_smtp_server = $server;
}
/**
* @return string
* @deprecated 2.5 See SS_Log on setting up error email notification
*/
public static function get_custom_smtp_server() {
return self::$custom_smtp_server;
}
/**
* Send errors to the given email address.
* Can be used like so:
* if(Director::isLive()) Debug::send_errors_to("sam@silverstripe.com");
*
* @deprecated 2.5 See SS_Log on setting up error email notification
*
* @param string $emailAddress The email address to send errors to
* @param string $sendWarnings Set to true to send warnings as well as errors (Default: false)
*/
public static function send_errors_to($emailAddress, $sendWarnings = false) {
Deprecation::notice('2.5', 'Use SS_Log instead. See SS_Log on setting up error email notification.');
self::$send_errors_to = $emailAddress;
self::$send_warnings_to = $sendWarnings ? $emailAddress : null;
}
/**
* @return string
* @deprecated 2.5 See SS_Log on setting up error email notification
*/
public static function get_send_errors_to() {
Deprecation::notice('2.5', 'Use SS_Log instead. See SS_Log on setting up error email notification.');
return self::$send_errors_to;
}
/**
* @param string $emailAddress
* @deprecated 2.5 See SS_Log on setting up error email notification
*/
public static function send_warnings_to($emailAddress) {
Deprecation::notice('2.5', 'Use SS_Log instead. See SS_Log on setting up error email notification.');
self::$send_warnings_to = $emailAddress;
}
/**
* @return string
* @deprecated 2.5 See SS_Log on setting up error email notification
*/
public static function get_send_warnings_to() {
Deprecation::notice('2.5', 'Use SS_Log instead. See SS_Log on setting up error email notification.');
return self::$send_warnings_to;
}
/**
* Call this to enable logging of errors.
* @deprecated 2.5 See SS_Log on setting up error file logging
*/
public static function log_errors_to($logFile = ".sserrors") {
Deprecation::notice('2.5', 'Use SS_Log instead. See SS_Log on setting up error file logging.');
self::$log_errors_to = $logFile;
}
public static function caller() {
$bt = debug_backtrace();
$caller = $bt[2];
$caller['line'] = $bt[1]['line'];
$caller['file'] = $bt[1]['file'];
if(!isset($caller['class'])) $caller['class'] = '';
if(!isset($caller['type'])) $caller['type'] = '';
return $caller;
}
/**
* @deprecated 2.5 Please use {@link SS_Backtrace::backtrace()}
*/
public static function backtrace($returnVal = false, $ignoreAjax = false) {
Deprecation::notice('2.5', 'Use SS_Backtrace::backtrace instead.');
return SS_Backtrace::backtrace($returnVal, $ignoreAjax);
}
/**
* @deprecated 2.5 Please use {@link SS_Backtrace::get_rendered_backtrace()}
*/
public static function get_rendered_backtrace($bt, $plainText = false) {
Deprecation::notice('2.5', 'Use SS_Backtrace::get_rendered_backtrace() instead.');
return SS_Backtrace::get_rendered_backtrace($bt, $plainText);
}
/**
* Check if the user has permissions to run URL debug tools,