From ce3f0cf140d4bf39cc5bf82c87e95b346bc5654e Mon Sep 17 00:00:00 2001 From: phpnut Date: Sun, 16 Sep 2007 01:36:30 +0000 Subject: [PATCH] Closes #1818, enhancement for the debug() function git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5646 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/basics.php | 16 +++++++++++++--- cake/libs/debugger.php | 8 ++++---- 2 files changed, 17 insertions(+), 7 deletions(-) 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 +?>