mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
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:
parent
1b64111871
commit
ce3f0cf140
2 changed files with 17 additions and 7 deletions
|
@ -764,10 +764,15 @@
|
||||||
* Only runs if debug level is non-zero.
|
* Only runs if debug level is non-zero.
|
||||||
*
|
*
|
||||||
* @param boolean $var Variable to show debug information for.
|
* @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 (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";
|
print "\n<pre class=\"cake_debug\">\n";
|
||||||
ob_start();
|
ob_start();
|
||||||
print_r($var);
|
print_r($var);
|
||||||
|
@ -950,10 +955,15 @@
|
||||||
* the output of given array. Similar to debug().
|
* the output of given array. Similar to debug().
|
||||||
*
|
*
|
||||||
* @see 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) {
|
function pr($var) {
|
||||||
if (Configure::read() > 0) {
|
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>";
|
echo "<pre>";
|
||||||
print_r($var);
|
print_r($var);
|
||||||
echo "</pre>";
|
echo "</pre>";
|
||||||
|
|
|
@ -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>]";
|
$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) {
|
if (Configure::read() > 0) {
|
||||||
debug($out);
|
debug($out, false, false);
|
||||||
e('<div id="CakeStackTrace' . count($_this->errors) . '" class="cake-stack-trace" style="display: none;">');
|
e('<div id="CakeStackTrace' . count($_this->errors) . '" class="cake-stack-trace" style="display: none;">');
|
||||||
if (!empty($context)) {
|
if (!empty($context)) {
|
||||||
$link = "document.getElementById(\"CakeErrorContext" . count($_this->errors) . "\").style.display = (document.getElementById(\"CakeErrorContext" . count($_this->errors) . "\").style.display == \"none\" ? \"\" : \"none\")";
|
$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) {
|
if (Configure::read() > 0) {
|
||||||
e("<div id=\"CakeErrorCode" . count($_this->errors) . "\" class=\"cake-code-dump\" style=\"display: none;\">");
|
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>');
|
e('</div>');
|
||||||
|
|
||||||
pr($_this->trace(array('start' => 1)));
|
pr($_this->trace(array('start' => 1)), false);
|
||||||
e('</div>');
|
e('</div>');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue