/** * Writes an exception to the plugin log. * * @param string $message * @param Exception $e */ private function logException($message, Exception $e) { $context = ['exception' => $e]; if ($e instanceof RequestException) { $context['response'] = $e->getResponse(); } $this->logger->error($message . ': ' . $e->getMessage(), $context); }
/** * calls every given url with the specific shop cookie * * @param string[] $urls * @param integer $shopId */ public function callUrls($urls, $shopId) { $shop = $this->getShopDataById($shopId); $guzzleConfig = []; if (!empty($shop["main_id"])) { //is not the main shop call url without shop cookie encoded in it $guzzleConfig['cookies'] = ['shop' => $shopId]; } foreach ($urls as $url) { $request = $this->guzzleClient->createRequest('GET', $url, $guzzleConfig); try { $this->guzzleClient->send($request); } catch (\Exception $e) { $this->logger->error("Warm up http-cache error with shopId " . $shopId . " " . $e->getMessage()); } } }
/** * @param Logger $log * @return mixed */ public function logResults(Logger $log) { if (empty($this->exceptions)) { return; } $rows = array(array('code', 'name', 'message', 'line', 'file', 'trace')); foreach ($this->exceptions as $exception) { $rows[] = $this->utils->encode(array($exception->getCode(), get_class($exception), $exception->getMessage(), $exception->getLine(), $exception->getFile(), explode("\n", $exception->getTraceAsString()))); } $table = array('Exception Log (' . count($this->exceptions) . ')', $rows); $log->table($table); foreach ($this->exceptions as $exception) { $log->error((string) $exception); } }