public function setUp()
 {
     date_default_timezone_set(self::DEFAULT_TIME_ZONE);
     $this->_logSrv = new LIB_Log();
     $this->_logid = LIB_Log::genLogID();
 }
Exemple #2
0
 public function testLogINFORESETMessage()
 {
     $this->_logSrv->write_log('info', 'Yun ji info');
     $expectedFilePath = 'output/login/login.' . date('Y-m-d') . '.log';
     $this->assertTrue(file_exists($expectedFilePath));
     $contents = $this->_get_log_json_array($expectedFilePath);
     $this->assertNotNull($contents);
     // Test the row just inserted.
     $lastRow = sizeof($contents) - 1;
     $this->assertEquals(15, strlen($contents[$lastRow]->logid));
     $logid = $contents[$lastRow]->logid;
     $timestamp = $contents[$lastRow]->timestamp;
     sleep(1);
     $this->_logSrv->write_log('info', 'Yun ji info');
     $expectedFilePath = 'output/login/login.' . date('Y-m-d') . '.log';
     $this->assertTrue(file_exists($expectedFilePath));
     $contents = $this->_get_log_json_array($expectedFilePath);
     $this->assertNotNull($contents);
     // Test the row just inserted.
     $lastRow = sizeof($contents) - 1;
     $this->assertEquals($logid, $contents[$lastRow]->logid);
     $this->assertEquals($timestamp, $contents[$lastRow]->timestamp);
     sleep(1);
     $this->_logSrv->init_notice(true);
     $this->_logSrv->write_log('info', 'Yun ji info');
     $expectedFilePath = 'output/login/login.' . date('Y-m-d') . '.log';
     $this->assertTrue(file_exists($expectedFilePath));
     $contents = $this->_get_log_json_array($expectedFilePath);
     $this->assertNotNull($contents);
     // Test the row just inserted.
     $lastRow = sizeof($contents) - 1;
     $this->assertEquals($logid, $contents[$lastRow]->logid);
     $this->assertFalse($timestamp === $contents[$lastRow]->timestamp);
     sleep(1);
     LIB_Log::genLogID(true);
     $this->_logSrv->init_notice(true);
     $this->_logSrv->write_log('info', 'Yun ji info');
     $expectedFilePath = 'output/login/login.' . date('Y-m-d') . '.log';
     $this->assertTrue(file_exists($expectedFilePath));
     $contents = $this->_get_log_json_array($expectedFilePath);
     $this->assertNotNull($contents);
     // Test the row just inserted.
     $lastRow = sizeof($contents) - 1;
     $this->assertFalse($logid === $contents[$lastRow]->logid);
     $this->assertFalse($timestamp === $contents[$lastRow]->timestamp);
 }
Exemple #3
0
<?php

require_once 'LIB_Log.php';
//生成一个session
$logSrv = new LIB_Log();
$logSrv->debug = TRUE;
echo "\n\n\n-------------------test write notice start-----------------------\n";
$logSrv->addlog('key', 'value');
$logSrv->write();
echo "-------------------test write notice   end-----------------------\n\n\n";
echo "\n\n\n-------------------test write notice write app start-----------------------\n";
$logSrv->addlog('key', 'value');
$logSrv->write('app');
echo "-------------------test write notice  write app  end-----------------------\n\n\n";
echo "\n\n\n-------------------test write rpc start-----------------------\n";
$logSrv->rpcstart();
$logSrv->writerpc(array('rpc_params' => 'rpc_value'));
echo "-------------------test write rpc  end-----------------------\n\n\n";
echo "\n\n\n-------------------test write warning start-----------------------\n";
$logSrv->rpcstart();
$logSrv->writewarning(array('warning_params' => 'warning_value'));
echo "-------------------test write warning  end-----------------------\n\n\n";