Permalink
Browse files

Fixed inconsistent debug parameters and empty '(line )'

  • Loading branch information...
markomarkovic committed Nov 4, 2011
1 parent 926ac32 commit 73429b357f06cd76f35d81482dd789b1737fe2b9
Showing with 13 additions and 5 deletions.
  1. +13 −5 lib/Cake/basics.php
@@ -76,39 +76,47 @@ function debug($var = false, $showHtml = null, $showFrom = true) {
if (Configure::read('debug') > 0) {
$file = '';
$line = '';
$lineInfo = '';
if ($showFrom) {
$calledFrom = debug_backtrace();
$file = substr(str_replace(ROOT, '', $calledFrom[0]['file']), 1);
$line = $calledFrom[0]['line'];
}
$html = <<<HTML
<div class="cake-debug-output">
<span><strong>%s</strong> (line <strong>%s</strong>)</span>
%s
<pre class="cake-debug">
%s
</pre>
</div>
HTML;
$text = <<<TEXT
$text = <<<TEXT
%s (line %s)
%s
########## DEBUG ##########
%s
###########################
TEXT;
$template = $html;
if (php_sapi_name() == 'cli') {
if (php_sapi_name() == 'cli' || $showHtml === false) {
$template = $text;
if ($showFrom) {
$lineInfo = sprintf('%s (line %s)', $file, $line);
}
}
if ($showHtml === null && $template !== $text) {
$showHtml = true;
}
$var = print_r($var, true);
if ($showHtml) {
$template = $html;
$var = h($var);
if ($showFrom) {
$lineInfo = sprintf('<span><strong>%s</strong> (line <strong>%s</strong>)</span>', $file, $line);
}
}
printf($template, $file, $line, $var);
printf($template, $lineInfo, $var);
}
}

0 comments on commit 73429b3

Please sign in to comment.