Changeset 1084
- Timestamp:
- 11/29/07 00:25:05 (9 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/main/php/net/stubbles/util/log/stubBaseLogData.php
r816 r1084 8 8 */ 9 9 stubClassLoader::load('net.stubbles.util.log.stubLogData', 10 'net.stubbles.util.log.stubLogger', 11 'net.stubbles.ipo.session.stubSession' 10 'net.stubbles.util.log.stubLogger' 12 11 ); 13 12 /** … … 53 52 * log appender will not mess up the log data. 54 53 * 55 * @param st ubSession $session the session of the current user56 * @param string $target target where the log data should go to57 * @param int $level optional log level of the log data54 * @param string $target target where the log data should go to 55 * @param int $level optional log level of the log data 56 * @param string $sessionId optional session id of current user 58 57 */ 59 public function __construct( stubSession $session, $target, $level = stubLogger::LEVEL_INFO)58 public function __construct($target, $level = stubLogger::LEVEL_INFO, $sessionId = null) 60 59 { 61 60 $this->target = $target; 62 61 $this->level = $level; 63 62 $this->logData = array(date('Y-m-d H:i:s'), 64 $session->getId()63 (string) $sessionId 65 64 ); 66 65 } trunk/src/main/php/net/stubbles/util/log/stubLogDataFactory.php
r887 r1084 33 33 $fqClassName = stubRegistry::getConfig('net.stubbles.util.log.class', 'net.stubbles.util.log.stubBaseLogData'); 34 34 $nqClassName = stubClassLoader::getNonQualifiedClassName($fqClassName); 35 if (class_exists($nqClassName, false) == false) {35 if (class_exists($nqClassName, false) === false) { 36 36 stubClassLoader::load($fqClassName); 37 37 } 38 38 39 $logData = new $nqClassName($ session, $target, $level);40 if (($logData instanceof stubLogData) == false) {39 $logData = new $nqClassName($target, $level, $session->getId()); 40 if (($logData instanceof stubLogData) === false) { 41 41 throw new stubRuntimeException('Configured net.stubbles.util.log.class is not an instance of stubLogData.'); 42 42 } trunk/src/test/php/net/stubbles/util/log/stubBaseLogDataTestCase.php
r146 r1084 1 1 <?php 2 2 /** 3 * Test for net .stubbles.util.log.stubBaseLogData.3 * Test for net::stubbles::util::log::stubBaseLogData. 4 4 * 5 5 * @author Frank Kleine <mikey@stubbles.net> … … 8 8 */ 9 9 stubClassLoader::load('net.stubbles.util.log.stubBaseLogData'); 10 Mock::generate('stubSession');11 10 /** 12 * Test for net .stubbles.util.log.stubBaseLogData.11 * Test for net::stubbles::util::log::stubBaseLogData. 13 12 * 14 13 * @package stubbles … … 18 17 { 19 18 /** 20 * instance to test 21 * 22 * @var stubBaseLogData 19 * assure that data is handles as expected 23 20 */ 24 protected $baseLogData; 25 26 /** 27 * set up the test environment 28 */ 29 public function setUp() 21 public function testWithSessionId() 30 22 { 31 $mockSession = new MockstubSession(); 32 $mockSession->setReturnValue('getId', 'foo'); 33 $this->baseLogData = new stubBaseLogData($mockSession, 'bar'); 23 $baseLogData = new stubBaseLogData('bar', stubLogger::LEVEL_INFO, 'foo'); 24 $this->assertEqual($baseLogData->getLevel(), stubLogger::LEVEL_INFO); 25 $this->assertEqual($baseLogData->getTarget(), 'bar'); 26 $baseLogData->addData("ba\r\nz" . stubLogData::SEPERATOR . 'vvv'); 27 $data = explode(stubLogData::SEPERATOR, $baseLogData->get()); 28 $this->assertEqual($data[1], 'foo'); 29 $this->assertEqual($data[2], 'ba<nl>zvvv'); 34 30 } 35 31 36 32 /** 37 33 * assure that data is handles as expected 38 34 */ 39 public function test Data()35 public function testWithoutSessionId() 40 36 { 41 $this->assertEqual($this->baseLogData->getLevel(), stubLogger::LEVEL_INFO); 42 $this->assertEqual($this->baseLogData->getTarget(), 'bar'); 43 $this->baseLogData->addData("ba\r\nz" . stubLogData::SEPERATOR . 'vvv'); 44 $data = explode(stubLogData::SEPERATOR, $this->baseLogData->get()); 45 $this->assertEqual($data[1], 'foo'); 37 $baseLogData = new stubBaseLogData('bar'); 38 $this->assertEqual($baseLogData->getLevel(), stubLogger::LEVEL_INFO); 39 $this->assertEqual($baseLogData->getTarget(), 'bar'); 40 $baseLogData->addData("ba\r\nz" . stubLogData::SEPERATOR . 'vvv'); 41 $data = explode(stubLogData::SEPERATOR, $baseLogData->get()); 42 $this->assertEqual($data[1], ''); 46 43 $this->assertEqual($data[2], 'ba<nl>zvvv'); 47 44 }
