diff --git a/cake/basics.php b/cake/basics.php index da0d6707b..f4c5b62c9 100644 --- a/cake/basics.php +++ b/cake/basics.php @@ -764,10 +764,15 @@ * Only runs if debug level is non-zero. * * @param boolean $var Variable to show debug information for. - * @param boolean $show_html If set to true, the method prints the debug data in a screen-friendly way. + * @param boolean $showHtml If set to true, the method prints the debug data in a screen-friendly way. + * @param boolean $showFrom If set to true, the method prints from where the function was called. */ - function debug($var = false, $showHtml = false) { + function debug($var = false, $showHtml = false, $showFrom = true) { if (Configure::read() > 0) { + if ($showFrom) { + $calledFrom = debug_backtrace(); + print "".substr(r(ROOT, "", $calledFrom[0]['file']), 1)." (line ".$calledFrom[0]['line'].")"; + } print "\n
\n"; ob_start(); print_r($var); @@ -950,10 +955,15 @@ * the output of given array. Similar to debug(). * * @see debug() - * @param array $var Variable to print out + * @param array $var Variable to print out + * @param boolean $showFrom If set to true, the method prints from where the function was called */ function pr($var) { if (Configure::read() > 0) { + if ($showFrom) { + $calledFrom = debug_backtrace(); + print "".substr(r(ROOT, "", $calledFrom[0]['file']), 1)." (line ".$calledFrom[0]['line'].")"; + } echo ""; print_r($var); echo ""; diff --git a/cake/libs/debugger.php b/cake/libs/debugger.php index 794a2759b..f9c9e4ed5 100644 --- a/cake/libs/debugger.php +++ b/cake/libs/debugger.php @@ -159,7 +159,7 @@ class Debugger extends Object { $out = "{$error} ({$code}): {$description} [{$file}, line {$line}]"; if (Configure::read() > 0) { - debug($out); + debug($out, false, false); e(' '); } @@ -440,4 +440,4 @@ if (!defined('DISABLE_DEFAULT_ERROR_HANDLING')) { Debugger::invoke(Debugger::getInstance()); } -?> \ No newline at end of file +?>