diff --git a/src/AppBundle/Command/ScraperCommand.php b/src/AppBundle/Command/ScraperCommand.php index ef6af83..97f1349 100644 --- a/src/AppBundle/Command/ScraperCommand.php +++ b/src/AppBundle/Command/ScraperCommand.php @@ -144,7 +144,7 @@ public function scrapeFacebook($partyCode, $socialNetworks) ->getFBData($partyCode, $socialNetworks['facebook']['username'], $this->scrapeData, $this->scrapeFull); if (!$fbData) { - $this->log->warning(" - ERROR while retrieving FB data for " . $partyCode); + $this->log->notice(" - ERROR while retrieving FB data for " . $partyCode); return false; } @@ -171,7 +171,7 @@ public function scrapeTwitter($partyCode, $socialNetworks) ->getTwitterData($partyCode, $socialNetworks['twitter']['username'], $this->scrapeData, $this->scrapeFull); if (!$twData) { - $this->log->warning(" - ERROR while retrieving Twitter data for " . $partyCode); + $this->log->notice(" - ERROR while retrieving Twitter data for " . $partyCode); return false; } @@ -198,7 +198,7 @@ public function scrapeGooglePlus($partyCode, $socialNetworks) ->getGooglePlusData($partyCode, $socialNetworks['googlePlus']); if (empty($gData)) { - $this->log->warning(" - ERROR while retrieving Google+ data for " . $partyCode); + $this->log->notice(" - ERROR while retrieving Google+ data for " . $partyCode); return false; } @@ -224,7 +224,7 @@ public function scrapeYoutube($partyCode, $socialNetworks) ->getYoutubeData($partyCode, $socialNetworks['youtube'], $this->scrapeData); if (!$ytData) { - $this->log->warning(" - ERROR while retrieving Youtube data for " . $partyCode); + $this->log->notice(" - ERROR while retrieving Youtube data for " . $partyCode); return false; } diff --git a/src/AppBundle/Service/ConnectionService.php b/src/AppBundle/Service/ConnectionService.php index 5c4a238..58e3723 100644 --- a/src/AppBundle/Service/ConnectionService.php +++ b/src/AppBundle/Service/ConnectionService.php @@ -26,17 +26,17 @@ public function __construct(Container $container) { public function exception_handler($e) { - $message = $e->getMessage(); - $this->log->error($message); - if ($message == "Application request limit reached") { $this->getFbRateLimit(); + } else { + $message = $e->getMessage(); + $this->log->error($message); } } /** - * Builds a Facebook Throttle Exception to test error handling + * Throws a Facebook Throttle Exception to test error handling */ public function testFbRateLimit() { $e = new FacebookThrottleException("Application request limit reached"); @@ -90,17 +90,14 @@ public function getFbGraphNode($fbPageId, $fields) { } catch(Facebook\Exceptions\FacebookThrottleException $e) { // When the app hits the rate limit - $this->log->error($fbPageId . " - " . $e->getMessage()); $response = $this->getFbRateLimit($request); } catch(\Exception $e) { - $this->log->error($fbPageId . " - Exception: " . $e->getMessage()); - if ($e->getMessage() == "Application request limit reached") { - $this->getFbRateLimit($request); - + $response = $this->getFbRateLimit($request); } else { - return false; + $this->log->error($fbPageId . " - Exception: " . $e->getMessage()); + return false; } } @@ -119,6 +116,8 @@ public function getFbGraphNode($fbPageId, $fields) { public function getFbRateLimit($request = null) { $connected = false; + $this->log->warning(" - Facebook rate limit reached!"); + if (is_null($request)) { $request = $this->fb->request('GET', $this->fbPageId, ['fields' => 'engagement']); } @@ -217,7 +216,7 @@ public function getTwRateLimit($tw) { // $this->log->debug(" + (" . $limitCheck['remaining'] . " requests remaining, resetting at " . date('H:i:s', $limitCheck['reset']) . ") "); if ($limitCheck['remaining'] < 2) { // give ourselves a little bit of wiggle room - $this->log->warning(" - Rate limit reached! Resuming at " . date('H:i:s', $limitCheck['reset']) . "..."); + $this->log->notice(" - Twitter rate limit reached! Resuming at " . date('H:i:s', $limitCheck['reset']) . "..."); time_sleep_until($limitCheck['reset']); } } diff --git a/src/AppBundle/Service/ImageService.php b/src/AppBundle/Service/ImageService.php index 22ef390..73c40f6 100644 --- a/src/AppBundle/Service/ImageService.php +++ b/src/AppBundle/Service/ImageService.php @@ -59,7 +59,7 @@ public function saveImage($site, $code, $imgSrc, $imgId, $imgBkp = null) { try { $imgData = file_get_contents($imgSrc, false, $ctx); } catch (\Exception $e) { - $this->log->warning($e->getMessage()); + $this->log->notice($e->getMessage()); if ($imgBkp) { // try backup if available try { $imgData = file_get_contents($imgBkp, false, $ctx); @@ -75,7 +75,7 @@ public function saveImage($site, $code, $imgSrc, $imgId, $imgBkp = null) { try { file_put_contents($imgPath, $imgData); } catch (\Exception $e) { - $this->log->warning($e->getMessage()); + $this->log->notice($e->getMessage()); } } @@ -110,7 +110,7 @@ public function getFacebookCover($partyCode, $imgSrc) { try { $imgData = file_get_contents($imgSrc, false, $ctx); } catch (\Exception $e) { - $this->log->warning($e->getMessage()); + $this->log->notice($e->getMessage()); } if (empty($imgData)) {