From b79c2149d9d08e37a3c6ce40ab2f5e664745e14b Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Wed, 16 Dec 2009 05:40:52 +0000 Subject: [PATCH] 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) (from r94423) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@95609 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- dev/Log.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/dev/Log.php b/dev/Log.php index 080d1ad7d..d820f1203 100644 --- a/dev/Log.php +++ b/dev/Log.php @@ -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) {