mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Fixing Debugger::log() . The method used protected properties only available in test cases. No stack trace was being logged when called either. Method has been updated to match its doc block better.
Fixes #222
This commit is contained in:
parent
ad305a890a
commit
a31a2d264c
2 changed files with 3 additions and 10 deletions
|
@ -139,16 +139,8 @@ class Debugger extends Object {
|
||||||
*/
|
*/
|
||||||
function log($var, $level = LOG_DEBUG) {
|
function log($var, $level = LOG_DEBUG) {
|
||||||
$_this = Debugger::getInstance();
|
$_this = Debugger::getInstance();
|
||||||
$trace = $_this->trace(array('start' => 1, 'depth' => 2, 'format' => 'array'));
|
$source = $_this->trace(array('start' => 1)) . "\n";
|
||||||
$source = null;
|
CakeLog::write($level, "\n" . $source . $_this->exportVar($var));
|
||||||
|
|
||||||
if (is_object($trace[0]['object']) && isset($trace[0]['object']->_reporter->_test_stack)) {
|
|
||||||
$stack = $trace[0]['object']->_reporter->_test_stack;
|
|
||||||
$source = sprintf('[%1$s, %3$s::%2$s()]' . "\n",
|
|
||||||
array_shift($stack), array_pop($stack), array_pop($stack));
|
|
||||||
}
|
|
||||||
|
|
||||||
CakeLog::write($level, $source . $_this->exportVar($var));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -226,6 +226,7 @@ class DebuggerTest extends CakeTestCase {
|
||||||
Debugger::log(array('whatever', 'here'));
|
Debugger::log(array('whatever', 'here'));
|
||||||
$result = file_get_contents(TMP . 'logs' . DS . 'debug.log');
|
$result = file_get_contents(TMP . 'logs' . DS . 'debug.log');
|
||||||
$this->assertPattern('/DebuggerTest\:\:testLog/', $result);
|
$this->assertPattern('/DebuggerTest\:\:testLog/', $result);
|
||||||
|
$this->assertPattern('/\[main\]/', $result);
|
||||||
$this->assertPattern('/array/', $result);
|
$this->assertPattern('/array/', $result);
|
||||||
$this->assertPattern('/"whatever",/', $result);
|
$this->assertPattern('/"whatever",/', $result);
|
||||||
$this->assertPattern('/"here"/', $result);
|
$this->assertPattern('/"here"/', $result);
|
||||||
|
|
Loading…
Add table
Reference in a new issue