Permalink
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...
1 parent ad305a8 commit a31a2d264c2cd128de2db839fa2901680c7de2ba @markstory markstory committed Oct 29, 2009
Showing with 3 additions and 10 deletions.
  1. +2 −10 cake/libs/debugger.php
  2. +1 −0 cake/tests/cases/libs/debugger.test.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));
}
/**
@@ -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);

0 comments on commit a31a2d2

Please sign in to comment.