From a31a2d264c2cd128de2db839fa2901680c7de2ba Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 29 Oct 2009 19:47:29 -0400 Subject: [PATCH] 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 --- cake/libs/debugger.php | 12 ++---------- cake/tests/cases/libs/debugger.test.php | 1 + 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/cake/libs/debugger.php b/cake/libs/debugger.php index 1e942e5f6..a49b39abb 100644 --- a/cake/libs/debugger.php +++ b/cake/libs/debugger.php @@ -139,16 +139,8 @@ class Debugger extends Object { */ 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)); } /** diff --git a/cake/tests/cases/libs/debugger.test.php b/cake/tests/cases/libs/debugger.test.php index 6f1f0162c..8f57cbbd0 100644 --- a/cake/tests/cases/libs/debugger.test.php +++ b/cake/tests/cases/libs/debugger.test.php @@ -226,6 +226,7 @@ class DebuggerTest extends CakeTestCase { 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);