From 5abb778b1656222ec68708bfb7be693fa50657fb Mon Sep 17 00:00:00 2001 From: frankwong Date: Tue, 22 Jan 2013 16:04:38 -0800 Subject: [PATCH 1/2] Added class and function information to log messages based on where the log message was initiated. --- laravel/log.php | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/laravel/log.php b/laravel/log.php index 88477a69..c7a9eadc 100644 --- a/laravel/log.php +++ b/laravel/log.php @@ -56,7 +56,31 @@ class Log { Event::fire('laravel.log', array($type, $message)); } - $message = static::format($type, $message); + $trace=debug_backtrace(); + + foreach($trace as $item) + { + if ($item['class'] == __CLASS__) + { + continue; + } + + $caller = $item; + + break; + } + + $function = $caller['function']; + if (isset($caller['class'])) + { + $class = $caller['class'] . '::'; + } + else + { + $class = ''; + } + + $message = static::format($type, $class . $function . ' - ' . $message); File::append(path('storage').'logs/'.date('Y-m-d').'.log', $message); } @@ -96,4 +120,4 @@ class Log { static::write($method, $parameters[0], $parameters[1]); } -} \ No newline at end of file +} From 023e11e6917c6e9a287701fea3fd7433ed01d41a Mon Sep 17 00:00:00 2001 From: frankwong Date: Wed, 23 Jan 2013 20:56:48 -0800 Subject: [PATCH 2/2] Fixed bug where laravel is generating error log from outside of application classes. --- laravel/log.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/laravel/log.php b/laravel/log.php index c7a9eadc..40b9c12c 100644 --- a/laravel/log.php +++ b/laravel/log.php @@ -60,7 +60,7 @@ class Log { foreach($trace as $item) { - if ($item['class'] == __CLASS__) + if (isset($item['class']) AND $item['class'] == __CLASS__) { continue; }