From d3be6edb4eec1fc8efb6b8a48a34aea1069fb6da Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Tue, 23 Aug 2011 14:34:59 +0200 Subject: [PATCH] ENHANCEMENT Allowing string arguments in SS_Log::log() --- dev/Log.php | 10 ++++++++++ dev/LogErrorEmailFormatter.php | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/dev/Log.php b/dev/Log.php index f1cce7599..51fbf74e5 100644 --- a/dev/Log.php +++ b/dev/Log.php @@ -133,6 +133,16 @@ class SS_Log { 'errline' => $message->getLine(), 'errcontext' => $message->getTrace() ); + } elseif(is_string($message)) { + $trace = SS_Backtrace::filtered_backtrace(); + $lastTrace = $trace[0]; + $message = array( + 'errno' => '', + 'errstr' => $message, + 'errfile' => @$lastTrace['file'], + 'errline' => @$lastTrace['line'], + 'errcontext' => $trace + ); } try { self::get_logger()->log($message, $priority); diff --git a/dev/LogErrorEmailFormatter.php b/dev/LogErrorEmailFormatter.php index 3f213be56..a37f73b81 100644 --- a/dev/LogErrorEmailFormatter.php +++ b/dev/LogErrorEmailFormatter.php @@ -49,7 +49,7 @@ class SS_LogErrorEmailFormatter implements Zend_Log_Formatter_Interface { $data .= "\n"; $relfile = Director::makeRelative($errfile); - if($relfile[0] == '/') $relfile = substr($relfile, 1); + if($relfile && $relfile[0] == '/') $relfile = substr($relfile, 1); $host = @$_SERVER['HTTP_HOST']; $uri = @$_SERVER['REQUEST_URI'];