Пример #1
0
 /**
  * @test
  * @group logger
  * @group logger-get-stacktrace
  **/
 public function エラー内容をトレースする()
 {
     try {
         throw new \Exception('これはテストです');
     } catch (\Exception $e) {
         $log = Logger::getStackTrace($e);
         $this->assertTrue(is_string($log));
     }
 }
Пример #2
0
 /**
  * エントリを解析して必要データを配列で返す
  *
  * @param  DOMElement $entry
  * @return array
  **/
 private function _parseEntry($entry)
 {
     try {
         $entry_date = $this->plugin->getEntryDate($entry);
         // 今日の登録されたエントリではない、またはTestData使用でなければそのまま返す
         if (date('Y-m-d') != $entry_date && $this->plugin->hasTestData() === false) {
             return array();
         }
         $url = false;
         $url = $this->plugin->getEntryUrl($entry);
         $html = $this->plugin->fetchHtml($url);
         $title = $this->plugin->getEntryTitle($html);
         $eyecatch = $this->plugin->getEyeCatchUrl($html);
         $movies = $this->plugin->getMoviesUrl($html);
         $result = array('title' => $title, 'url' => $url, 'eyecatch' => $eyecatch, 'image_src' => '', 'movies' => $movies);
     } catch (CrawlerException $e) {
         if ($url !== false) {
             Logger::addLog($url);
         }
         Logger::addLog($e->getMessage());
         Logger::addLog($this->plugin->getSiteName() . PHP_EOL);
         $result = array();
     } catch (\Exception $e) {
         if ($url !== false) {
             Logger::addLog($url);
         }
         Logger::addLog($e->getMessage());
         Logger::addLog(Logger::getStackTrace($e) . PHP_EOL);
         $result = array();
     }
     return $result;
 }
Пример #3
0
 /**
  * クロール中に発生したエラーログをメール送信する
  *
  * @param  Exception $e
  * @return void
  **/
 private function _sendErrorLog($e)
 {
     $ses = new Ses();
     $ses->setTitle('Crawl Error!');
     $ses->setBody(Logger::getStackTrace($e));
     $ses->send();
 }