Example #1
0
 /**
  * 写日志操作
  * @param array|string $data
  * @return string 插入成功的id
  * @throws \mysoft\log\Exception
  */
 protected function create($data)
 {
     try {
         $this->_check_data($data);
         $result = $this->client->createDoc($this->index, $this->type, $data);
         if (isset($result['_id'])) {
             return $result['_id'];
         }
         throw new \Exception(print_r($result, true));
         //对于结构不对的直接抛出异常
     } catch (\Exception $ex) {
         if ($this->debug === false) {
             return false;
         }
         throw $ex;
     }
 }