Skip to content

Commit

Permalink
Fixing Debugger::log() . The method used protected properties only av…
Browse files Browse the repository at this point in the history
…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
markstory committed Oct 29, 2009
1 parent ad305a8 commit a31a2d2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
12 changes: 2 additions & 10 deletions cake/libs/debugger.php
Expand Up @@ -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));
}

/**
Expand Down
1 change: 1 addition & 0 deletions cake/tests/cases/libs/debugger.test.php
Expand Up @@ -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);
Expand Down

0 comments on commit a31a2d2

Please sign in to comment.