示例#1
0
 public function test2()
 {
     // set logger
     $logConfig = array('name' => '', 'file' => 'test.log', 'dir' => '../', 'level' => 'info');
     $today = date('Ymd');
     SLog::createLogger($logConfig);
     SLog::info('log');
     SLog::destroyLogger();
     $logFile = "../test_{$today}.log";
     if (file_exists($logFile)) {
         $this->assertTrue(true);
         // remove log for next test
         unlink($logFile);
     } else {
         $this->assertTrue(false);
     }
 }
示例#2
0
文件: SSql.php 项目: amkt922/ssql
 private function setConfigFromArray($config)
 {
     if (!in_array('database', $config) && !is_array($config['database'])) {
         throw new InvalidArgumentException('The parameter sould include database and it should be an array.');
     }
     if (!array_key_exists('dsn', $config['database'])) {
         throw new InvalidArgumentException('dsn value should be in database array.');
     }
     $database = $config['database'];
     $this->con = DriverManager::getConnection($database);
     // set directory config for sql files.
     if (array_key_exists('sqlDir', $config)) {
         $this->sqlDir = $config['sqlDir'];
     }
     // runtime config
     if (array_key_exists('runtimeConfig', $config)) {
         $this->runtimeConfig = $config['runtimeConfig'];
     }
     // set logger
     $logConfig = array();
     if (array_key_exists('log', $config)) {
         $logConfig = $config['log'];
     }
     SLog::createLogger($logConfig);
 }
示例#3
0
    private function executeLog($sql, $result)
    {
        $resultNum = count($result);
        $message = <<<MSG
<<<<<<<<<<start 
call SQueryManager::execute 
result num is {$resultNum}
SQL
{$sql}
>>>>>>>>>>end

MSG;
        SLog::info($message);
    }