mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
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:
parent
a99c211f76
commit
7b17559ded
11
dev/Log.php
11
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) {
|
||||
|
Loading…
Reference in New Issue
Block a user