Merge pull request #1639 from frankwong/master

Add calling class and function information in logs
This commit is contained in:
Taylor Otwell 2013-03-28 15:08:05 -07:00
commit 52e9cd5c09
1 changed files with 26 additions and 2 deletions

View File

@ -56,7 +56,31 @@ public static function write($type, $message, $pretty_print = false)
Event::fire('laravel.log', array($type, $message));
}
$message = static::format($type, $message);
$trace=debug_backtrace();
foreach($trace as $item)
{
if (isset($item['class']) AND $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 @@ public static function __callStatic($method, $parameters)
static::write($method, $parameters[0], $parameters[1]);
}
}
}