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
This commit is contained in:
phpnut 2007-09-16 01:36:30 +00:00
parent 1b64111871
commit ce3f0cf140
2 changed files with 17 additions and 7 deletions

View file

@ -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 "<strong>".substr(r(ROOT, "", $calledFrom[0]['file']), 1)."</strong> (line <strong>".$calledFrom[0]['line']."</strong>)";
}
print "\n<pre class=\"cake_debug\">\n";
ob_start();
print_r($var);
@ -951,9 +956,14 @@
*
* @see debug()
* @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 "<strong>".substr(r(ROOT, "", $calledFrom[0]['file']), 1)."</strong> (line <strong>".$calledFrom[0]['line']."</strong>)";
}
echo "<pre>";
print_r($var);
echo "</pre>";

View file

@ -159,7 +159,7 @@ class Debugger extends Object {
$out = "<a href='javascript:void(0);' onclick='{$link}'><b>{$error}</b> ({$code})</a>: {$description} [<b>{$file}</b>, line <b>{$line}</b>]";
if (Configure::read() > 0) {
debug($out);
debug($out, false, false);
e('<div id="CakeStackTrace' . count($_this->errors) . '" class="cake-stack-trace" style="display: none;">');
if (!empty($context)) {
$link = "document.getElementById(\"CakeErrorContext" . count($_this->errors) . "\").style.display = (document.getElementById(\"CakeErrorContext" . count($_this->errors) . "\").style.display == \"none\" ? \"\" : \"none\")";
@ -184,10 +184,10 @@ class Debugger extends Object {
if (Configure::read() > 0) {
e("<div id=\"CakeErrorCode" . count($_this->errors) . "\" class=\"cake-code-dump\" style=\"display: none;\">");
pr(implode("\n", $listing));
pr(implode("\n", $listing), false);
e('</div>');
pr($_this->trace(array('start' => 1)));
pr($_this->trace(array('start' => 1)), false);
e('</div>');
}