diff --git a/cake/basics.php b/cake/basics.php index c553a294d..602bec763 100644 --- a/cake/basics.php +++ b/cake/basics.php @@ -92,33 +92,39 @@ */ function debug($var = false, $showHtml = false, $showFrom = true) { if (Configure::read('debug') > 0) { + $file = ''; + $line = ''; if ($showFrom) { $calledFrom = debug_backtrace(); - if(defined('CAKEPHP_SHELL')){ - echo "##########DEBUG##########\n"; - echo substr(str_replace(ROOT, '', $calledFrom[0]['file']), 1) ; - echo ' (line ' . $calledFrom[0]['line'] . ')'."\n"; - }else{ - echo '' . substr(str_replace(ROOT, '', $calledFrom[0]['file']), 1) . ''; - echo ' (line ' . $calledFrom[0]['line'] . ')'; - } - } - if(!defined('CAKEPHP_SHELL')){ - echo "\n
\n";
+				$file = substr(str_replace(ROOT, '', $calledFrom[0]['file']), 1);
+				$line = $calledFrom[0]['line'];
 			}
+			$html = <<%s (line %s)
+
+%s
+
+HTML; + $text = <<', '>', $var)); } - echo $var . "\n"; - if(!defined('CAKEPHP_SHELL')){ - echo "
\n";
-			}else{
-				echo "#########################\n";
-			};
+			printf($template, $file, $line, $var);
 		}
 	}
+
 if (!function_exists('sortByKey')) {
 
 /**
diff --git a/cake/tests/cases/basics.test.php b/cake/tests/cases/basics.test.php
index 723254a20..6972e0315 100644
--- a/cake/tests/cases/basics.test.php
+++ b/cake/tests/cases/basics.test.php
@@ -585,7 +585,7 @@ class BasicsTest extends CakeTestCase {
 		ob_start();
 			debug('this-is-a-test');
 		$result = ob_get_clean();
-		$pattern = '/.*\>(.+?tests(\/|\\\)cases(\/|\\\)basics\.test\.php|';
+		$pattern = '/(.+?tests(\/|\\\)cases(\/|\\\)basics\.test\.php|';
 		$pattern .= preg_quote(substr(__FILE__, 1), '/') . ')';
 		$pattern .= '.*line.*' . (__LINE__ - 4) . '.*this-is-a-test.*/s';
 		$this->assertPattern($pattern, $result);
@@ -593,7 +593,7 @@ class BasicsTest extends CakeTestCase {
 		ob_start();
 			debug('
this-is-a-test
', true); $result = ob_get_clean(); - $pattern = '/.*\>(.+?tests(\/|\\\)cases(\/|\\\)basics\.test\.php|'; + $pattern = '/(.+?tests(\/|\\\)cases(\/|\\\)basics\.test\.php|'; $pattern .= preg_quote(substr(__FILE__, 1), '/') . ')'; $pattern .= '.*line.*' . (__LINE__ - 4) . '.*<div>this-is-a-test<\/div>.*/s'; $this->assertPattern($pattern, $result);