MINOR Added NOTICE level priority to SSLog

MINOR Added @deprecated php tag to deprecated functions in the Debug class
MINOR Class documentation for SSLog and Debug



git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@84811 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sean Harvey 2009-08-19 05:41:58 +00:00
parent e13316d0dc
commit 2c703c8a84
3 changed files with 23 additions and 21 deletions

View File

@ -2,11 +2,9 @@
/** /**
* Supports debugging and core error handling. * Supports debugging and core error handling.
* *
* Attaches custom methods to the default * Attaches custom methods to the default error handling hooks
* error handling hooks in PHP. Currently, three levels * in PHP. Currently, two levels of error are supported:
* of error are supported:
* *
* - Notice
* - Warning * - Warning
* - Error * - Error
* *
@ -16,24 +14,16 @@
* Uncaught exceptions are currently passed to the debug * Uncaught exceptions are currently passed to the debug
* reporter as standard PHP errors. * reporter as standard PHP errors.
* *
* There are four different types of error handler supported by the * Errors handled by this class are passed along to {@link SSLog}.
* Debug class: * For configuration information, see the {@link SSLog}
* class documentation.
* *
* - Friendly
* - Fatal
* - Logger
* - Emailer
*
* Currently, only Friendly, Fatal, and Emailer handlers are implemented.
*
* @todo port header/footer wrapping code to external reporter class
* @todo add support for user defined config: Debug::die_on_notice(true | false) * @todo add support for user defined config: Debug::die_on_notice(true | false)
* @todo add appropriate handling for E_NOTICE and E_USER_NOTICE levels * @todo add appropriate handling for E_NOTICE and E_USER_NOTICE levels
* @todo better way of figuring out the error context to display in highlighted source * @todo better way of figuring out the error context to display in highlighted source
* @todo implement error logger handler
* *
* @package sapphire * @package sapphire
* @subpackage core * @subpackage dev
*/ */
class Debug { class Debug {
@ -270,7 +260,7 @@ class Debug {
self::showError($errno, $errstr, $errfile, $errline, $errcontext, "Error"); self::showError($errno, $errstr, $errfile, $errline, $errcontext, "Error");
} else { } else {
Debug::friendlyError(); self::friendlyError();
} }
exit(1); exit(1);
} }
@ -461,6 +451,7 @@ class Debug {
/** /**
* @param string $server IP-Address or domain * @param string $server IP-Address or domain
* @deprecated 2.5 See SSLog on setting up error email notification
*/ */
static function set_custom_smtp_server($server) { static function set_custom_smtp_server($server) {
self::$custom_smtp_server = $server; self::$custom_smtp_server = $server;
@ -468,6 +459,7 @@ class Debug {
/** /**
* @return string * @return string
* @deprecated 2.5 See SSLog on setting up error email notification
*/ */
static function get_custom_smtp_server() { static function get_custom_smtp_server() {
return self::$custom_smtp_server; return self::$custom_smtp_server;
@ -478,6 +470,8 @@ class Debug {
* Can be used like so: * Can be used like so:
* if(Director::isLive()) Debug::send_errors_to("sam@silverstripe.com"); * if(Director::isLive()) Debug::send_errors_to("sam@silverstripe.com");
* *
* @deprecated 2.5 See SSLog on setting up error email notification
*
* @param string $emailAddress The email address to send errors to * @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) * @param string $sendWarnings Set to true to send warnings as well as errors (Default: false)
*/ */
@ -488,6 +482,7 @@ class Debug {
/** /**
* @return string * @return string
* @deprecated 2.5 See SSLog on setting up error email notification
*/ */
static function get_send_errors_to() { static function get_send_errors_to() {
return self::$send_errors_to; return self::$send_errors_to;
@ -495,6 +490,7 @@ class Debug {
/** /**
* @param string $emailAddress * @param string $emailAddress
* @deprecated 2.5 See SSLog on setting up error email notification
*/ */
static function send_warnings_to($emailAddress) { static function send_warnings_to($emailAddress) {
self::$send_warnings_to = $emailAddress; self::$send_warnings_to = $emailAddress;
@ -502,6 +498,7 @@ class Debug {
/** /**
* @return string * @return string
* @deprecated 2.5 See SSLog on setting up error email notification
*/ */
static function get_send_warnings_to() { static function get_send_warnings_to() {
return self::$send_warnings_to; return self::$send_warnings_to;

View File

@ -5,13 +5,15 @@
* sends it to one or more {@link Zend_Log_Writer_Abstract} * sends it to one or more {@link Zend_Log_Writer_Abstract}
* subclasses for output. * subclasses for output.
* *
* The only priorities currently supported are SSLog::ERR and * These priorities are currently supported:
* SSLog::WARN - this may change in the future if other types * - SSLog::ERR
* are to be supported. * - SSLog::WARN
* - SSLog::NOTICE
* *
* You can add an error writer by calling {@link SSLog::add_writer()} * You can add an error writer by calling {@link SSLog::add_writer()}
* *
* Example usage (called from mysite/_config.php): * Example usage (called from mysite/_config.php) which adds a writer
* that will write all errors:
* <code> * <code>
* $emailWriter = new SSErrorEmailWriter('my@email.com'); * $emailWriter = new SSErrorEmailWriter('my@email.com');
* SSLog::add_writer($emailWriter, SSLog::ERR); * SSLog::add_writer($emailWriter, SSLog::ERR);
@ -27,6 +29,7 @@ class SSLog {
const ERR = Zend_Log::ERR; const ERR = Zend_Log::ERR;
const WARN = Zend_Log::WARN; const WARN = Zend_Log::WARN;
const NOTICE = Zend_Log::NOTICE;
/** /**
* Logger class to use. * Logger class to use.

View File

@ -3,6 +3,8 @@
* Sends an error message to an email whenever an error occurs * Sends an error message to an email whenever an error occurs
* in sapphire. * in sapphire.
* *
* @see SSLog for more information on using writers.
*
* @package sapphire * @package sapphire
* @subpackage dev * @subpackage dev
*/ */