Example #1
0
 public function test設定したデータベースにログを書き込める()
 {
     $appPath = dirname(__FILE__);
     $obj = Db_Fixture::load($appPath . '/var/config/database.json');
     $pdo = $obj->getConnection();
     $file = file_get_contents($appPath . '/testdata/create.sql');
     $stmt = $pdo->prepare($file);
     $ret = $stmt->execute();
     $stmt = null;
     $config = new Zend_Config_Ini($appPath . '/var/config/log.ini');
     $instance = new Gene_Log($config->production->toArray());
     $logger = $instance->createLogger('default', 'db');
     $logger->info('This is a test.');
     $stmt = $pdo->prepare('SELECT * FROM gene_log_test');
     $ret = $stmt->execute();
     $rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
     $stmt = null;
     foreach ($rows as $row) {
         $this->assertEquals($row['priority'], Zend_Log::INFO);
         $this->assertEquals($row['message'], 'This is a test.');
     }
     $obj->after();
 }
Example #2
0
 /**
  * Create logger
  *
  * @access protected
  * @return Gene_Bootstrap Fluent interface
  */
 protected function _initLog()
 {
     // Load config file
     $path = $this->_configPath . 'log.ini';
     $config = Gene_Config::load($path, $this->_cache);
     if (is_null($config)) {
         return $this;
     }
     $env = $this->getEnvironment();
     if (isset($config->{$env})) {
         $config = $config->{$env};
     }
     // Create logger
     $log = new Gene_Log($config);
     $logger = $log->createLogger();
     $this->setParam('log', $log);
     return $this;
 }