remove autologging

This commit is contained in:
euromark 2013-09-13 02:28:25 +02:00
parent 130ccf4714
commit 61b05c40c6
2 changed files with 16 additions and 30 deletions

View file

@ -371,18 +371,6 @@ class CakeLog {
return false; return false;
} }
/**
* Configures the automatic/default stream a FileLog.
*
* @return void
*/
protected static function _autoConfig() {
self::$_Collection->load('default', array(
'engine' => 'File',
'path' => LOGS,
));
}
/** /**
* Writes the given message and type to all of the configured log adapters. * Writes the given message and type to all of the configured log adapters.
* Configured adapters are passed both the $type and $message variables. $type * Configured adapters are passed both the $type and $message variables. $type
@ -454,11 +442,7 @@ class CakeLog {
$logged = true; $logged = true;
} }
} }
if (!$logged) { return $logged;
self::_autoConfig();
self::stream('default')->write($type, $message);
}
return true;
} }
/** /**

View file

@ -126,27 +126,20 @@ class CakeLogTest extends CakeTestCase {
} }
/** /**
* Test that CakeLog autoconfigures itself to use a FileLogger with the LOGS dir. * Test that CakeLog does not auto create logs when no streams are there to listen.
* When no streams are there.
* *
* @return void * @return void
*/ */
public function testAutoConfig() { public function testNoStreamListenting() {
if (file_exists(LOGS . 'error.log')) { if (file_exists(LOGS . 'error.log')) {
unlink(LOGS . 'error.log'); unlink(LOGS . 'error.log');
} }
CakeLog::write(LOG_WARNING, 'Test warning'); $res = CakeLog::write(LOG_WARNING, 'Test warning');
$this->assertTrue(file_exists(LOGS . 'error.log')); $this->assertFalse($res);
$this->assertFalse(file_exists(LOGS . 'error.log'));
$result = CakeLog::configured(); $result = CakeLog::configured();
$this->assertEquals(array('default'), $result); $this->assertEquals(array(), $result);
$testMessage = 'custom message';
CakeLog::write('custom', $testMessage);
$content = file_get_contents(LOGS . 'custom.log');
$this->assertContains($testMessage, $content);
unlink(LOGS . 'error.log');
unlink(LOGS . 'custom.log');
} }
/** /**
@ -197,6 +190,10 @@ class CakeLogTest extends CakeTestCase {
* @return void * @return void
*/ */
public function testLogFileWriting() { public function testLogFileWriting() {
CakeLog::config('file', array(
'engine' => 'File',
'path' => LOGS
));
if (file_exists(LOGS . 'error.log')) { if (file_exists(LOGS . 'error.log')) {
unlink(LOGS . 'error.log'); unlink(LOGS . 'error.log');
} }
@ -503,6 +500,11 @@ class CakeLogTest extends CakeTestCase {
$this->_resetLogConfig(); $this->_resetLogConfig();
$this->_deleteLogs(); $this->_deleteLogs();
CakeLog::config('file', array(
'engine' => 'File',
'path' => LOGS
));
CakeLog::write('bogus', 'bogus message'); CakeLog::write('bogus', 'bogus message');
$this->assertTrue(file_exists(LOGS . 'bogus.log')); $this->assertTrue(file_exists(LOGS . 'bogus.log'));
$this->assertFalse(file_exists(LOGS . 'error.log')); $this->assertFalse(file_exists(LOGS . 'error.log'));