mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-06 11:32:40 +00:00
adding Debugger::log() and test cases, closes #995
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6300 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
695ac50fd7
commit
618d7bd84a
2 changed files with 47 additions and 1 deletions
|
@ -112,6 +112,22 @@ class Debugger extends Object {
|
|||
$_this = Debugger::getInstance();
|
||||
pr($_this->exportVar($var));
|
||||
}
|
||||
/**
|
||||
* neatly logs a given var
|
||||
*/
|
||||
function log($var, $level = 7) {
|
||||
$_this = Debugger::getInstance();
|
||||
$trace = $_this->trace(array('start' => 1, 'depth' => 2, 'format' => 'array'));
|
||||
$source = null;
|
||||
|
||||
if (is_object($trace[0]['object']) && isset($trace[0]['object']->_reporter->_test_stack)) {
|
||||
$stack = $trace[0]['object']->_reporter->_test_stack;
|
||||
$source = "[". $stack[0].", ". $stack[2] ."::" . $stack[3] ."()]\n";
|
||||
}
|
||||
|
||||
CakeLog::write($level, $source . $_this->exportVar($var));
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides PHP's default error handling
|
||||
*
|
||||
|
@ -255,6 +271,8 @@ class Debugger extends Object {
|
|||
$back[] = array('file' => $trace['file'], 'line' => $trace['line']);
|
||||
} elseif (empty($options['format'])) {
|
||||
$back[] = $function . ' - ' . Debugger::trimPath($trace['file']) . ', line ' . $trace['line'];
|
||||
} else {
|
||||
$back[] = $trace;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -438,7 +456,7 @@ class Debugger extends Object {
|
|||
|
||||
$files = $_this->trace(array('start' => 2, 'format' => 'points'));
|
||||
$listing = $_this->excerpt($files[0]['file'], $files[0]['line'] - 1, 1);
|
||||
$trace = $_this->trace(array('start' => 2));
|
||||
$trace = $_this->trace(array('start' => 2, 'depth' => '20'));
|
||||
$context = array();
|
||||
|
||||
foreach ((array)$kontext as $var => $value) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue