Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixing Debugger::log() . The method used protected properties only av…

…ailable in test cases. No stack trace was being logged when called either. Method has been updated to match its doc block better.

Fixes #222
  • Loading branch information...
commit a31a2d264c2cd128de2db839fa2901680c7de2ba 1 parent ad305a8
Mark Story markstory authored
Showing with 3 additions and 10 deletions.
  1. +2 −10 cake/libs/debugger.php
  2. +1 −0  cake/tests/cases/libs/debugger.test.php
12 cake/libs/debugger.php
View
@@ -139,16 +139,8 @@ function dump($var) {
*/
function log($var, $level = LOG_DEBUG) {
$_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 = sprintf('[%1$s, %3$s::%2$s()]' . "\n",
- array_shift($stack), array_pop($stack), array_pop($stack));
- }
-
- CakeLog::write($level, $source . $_this->exportVar($var));
+ $source = $_this->trace(array('start' => 1)) . "\n";
+ CakeLog::write($level, "\n" . $source . $_this->exportVar($var));
}
/**
1  cake/tests/cases/libs/debugger.test.php
View
@@ -226,6 +226,7 @@ function testLog() {
Debugger::log(array('whatever', 'here'));
$result = file_get_contents(TMP . 'logs' . DS . 'debug.log');
$this->assertPattern('/DebuggerTest\:\:testLog/', $result);
+ $this->assertPattern('/\[main\]/', $result);
$this->assertPattern('/array/', $result);
$this->assertPattern('/"whatever",/', $result);
$this->assertPattern('/"here"/', $result);
Please sign in to comment.
Something went wrong with that request. Please try again.