ENHANCEMENT Allow passing in an Exception object to SS_Log::log() in addition to an array describing the error context (line number, file, trace etc)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@94423 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sean Harvey 2009-12-05 06:03:24 +00:00 committed by Sam Minnee
parent a99c211f76
commit 7b17559ded

View File

@ -122,10 +122,19 @@ class SS_Log {
* along a list of debug information for the writer to handle, such as
* error code, error line, error context (backtrace).
*
* @param string|array $message String of error message, or array of variables
* @param mixed $message Exception object or array of error context variables
* @param const $priority Priority. Possible values: SS_Log::ERR, SS_Log::WARN or SS_Log::NOTICE
*/
public static function log($message, $priority) {
if($message instanceof Exception) {
$message = array(
'errno' => '',
'errstr' => $message->getMessage(),
'errfile' => $message->getFile(),
'errline' => $message->getLine(),
'errcontext' => $message->getTrace()
);
}
try {
self::get_logger()->log($message, $priority);
} catch(Exception $e) {