warning() public method

Example: Use of deprecated APIs, poor use of an API, undesirable things that are not necessarily wrong.
public warning ( string $message, array $context = [] ) : null
$message string
$context array
return null
 /**
  * @param $statusCode
  * @param $url
  * @param RequestInterface $request
  * @param Response $response
  */
 public function validate($statusCode, $url, RequestInterface $request, Response $response)
 {
     if ($response->getStatusCode() === $statusCode) {
         return;
     }
     $message = $url . ' gives a non-200 status code response.';
     $this->logger->warning($message, array('request' => (string) $request, 'response' => (string) $response));
     throw new RuntimeException($message . ' See logs.' . $response->serialize());
 }
Esempio n. 2
0
 /** {@inheritdoc} */
 public function getController(RequestInterface $request)
 {
     if (!($controller = $request->getAttributes()->get('_controller'))) {
         $this->logger->warning('Unable to look for the controller as the "_controller" parameter is missing.');
         return false;
     }
     if (is_array($controller)) {
         return $controller;
     }
     if (is_object($controller)) {
         if (method_exists($controller, '__invoke')) {
             return $controller;
         }
         throw new \InvalidArgumentException(sprintf('Controller "%s" for method "%s" is not callable.', get_class($controller), $request->getMethod()));
     }
     if (false === strpos($controller, ':')) {
         if (method_exists($controller, '__invoke')) {
             return $this->instantiateController($controller);
         } elseif (function_exists($controller)) {
             return $controller;
         }
     }
     $callable = $this->createController($controller);
     if (!is_callable($callable)) {
         throw new \InvalidArgumentException(sprintf('The controller for method "%s" is not callable. %s', $request->getMethod(), $this->getControllerError($callable)));
     }
     return $callable;
 }
Esempio n. 3
0
 public function postModule(PostModuleEvent $event)
 {
     $pageModuleWrapper = $event->getModuleWrapper();
     $queryCount = $event->getExtra('module_profiler.query_count');
     $time = microtime(true) - $event->getExtra('module_profiler.time');
     $userTime = Helper::getCpuTime('u') - $event->getExtra('module_profiler.user_time');
     $systemTime = Helper::getCpuTime('s') - $event->getExtra('module_profiler.system_time');
     $memoryUsage = memory_get_usage(true) - $event->getExtra('module_profiler.memory_usage');
     $sqlQueries = $queryCount !== null ? Propel::getQueryCount() - $queryCount : null;
     if ($userTime + $systemTime > $this->cpuLimit || $time > $this->timeLimit) {
         $this->logger->warning('Module generation time exceeded limit');
     }
     if ($memoryUsage > $this->memoryLimit) {
         $this->logger->warning('Module memory usage exceeded limit');
     }
     if ($sqlQueries > $this->sqlLimit) {
         $this->logger->warning('Module sql query count exceeded limit');
     }
     // add module debug info
     $this->moduleDebugInfo[] = array($pageModuleWrapper->getName(), $pageModuleWrapper->getClassName(), $pageModuleWrapper->getTemplate(), $pageModuleWrapper->getTarget(), (bool) $event->getExtra('module_cacher.cached'), round($time * 1000.0), round(($userTime + $systemTime) * 1000.0), Helper::humanReadableBytes($memoryUsage), Helper::humanReadableBytes(memory_get_peak_usage(true)), $sqlQueries !== null ? $sqlQueries : 'n/a');
     // Remove values to prevent caching
     $extras = $event->getExtras();
     unset($extras['module_profiler.time']);
     unset($extras['module_profiler.query_count']);
     unset($extras['module_profiler.user_time']);
     unset($extras['module_profiler.system_time']);
     unset($extras['module_profiler.memory_usage']);
     $event->setExtras($extras);
 }
Esempio n. 4
0
 /**
  * {@inheritdoc}
  */
 public function log($message, $level)
 {
     $message .= ' ' . $this->request->getRequestUri();
     if ($this->logLevel >= $level) {
         switch ($level) {
             case self::EMERGENCY:
                 $this->logger->emergency($message);
                 break;
             case self::ALERT:
                 $this->logger->alert($message);
                 break;
             case self::CRITICAL:
                 $this->logger->critical($message);
                 break;
             case self::ERROR:
                 $this->logger->error($message);
                 break;
             case self::WARNING:
                 $this->logger->warning($message);
                 break;
             case self::NOTICE:
                 $this->logger->notice($message);
                 break;
             case self::INFO:
                 $this->logger->info($message);
                 break;
             default:
                 $this->logger->debug($message);
         }
     }
 }
Esempio n. 5
0
 /**
  * @param string $username
  * @param string $password
  * @param null|string $requiredGroupRole
  * @return bool
  */
 public function login($username, $password, $requiredGroupRole = null)
 {
     if (empty($username) || empty($password)) {
         return false;
     }
     $user = $this->userProvider->loadUserByUsername($username);
     if (!$user) {
         $this->logger->warning(sprintf('Login failed for "%s". User not found', $username));
         sleep(1);
         return false;
     }
     if (null !== $requiredGroupRole) {
         $groupRoles = $user->getGroupRoles();
         if (!in_array($requiredGroupRole, $groupRoles)) {
             $this->logger->warning(sprintf('Login failed for "%s". Not in requested group role "%s" vs "%s"', $username, $requiredGroupRole, implode(',', $groupRoles)));
             sleep(1);
             return false;
         }
     }
     $encoder = $this->encoderFactory->getEncoder($user);
     if (!$encoder->isPasswordValid($user->getPassword(), $password, null)) {
         $this->logger->warning(sprintf('Login failed for "%s". Password missmatch ', $username));
         sleep(1);
         return false;
     }
     $this->manualLogin($user);
     return true;
 }
 /**
  * Log the state of the analysis.
  *
  * @param \StyleCI\StyleCI\Models\Analysis
  *
  * @return void
  */
 protected function logState(Analysis $analysis)
 {
     switch ($analysis->status) {
         case Analysis::PENDING:
             $this->logger->debug('Analysis has been queued.', $this->getContext($analysis));
             break;
         case Analysis::RUNNING:
             $this->logger->debug('Analysis has started running.', $this->getContext($analysis));
             break;
         case Analysis::PASSED:
         case Analysis::CS_ISSUES:
         case Analysis::SYNTAX_ISSUES:
         case Analysis::BOTH_ISSUES:
             $this->logger->debug('Analysis has completed successfully.', $this->getContext($analysis));
             break;
         case Analysis::CONFIG_ISSUES:
             $this->logger->notice('Analysis has failed due to misconfiguration.', $this->getContext($analysis));
             break;
         case Analysis::ACCESS_ISSUES:
             $this->logger->warning('Analysis has failed due to git access issues.', $this->getContext($analysis));
             break;
         case Analysis::TIMEOUT:
             $this->logger->error('Analysis has failed due to a platform timeout.', $this->getContext($analysis));
             break;
         default:
             $this->logger->error('Analysis has failed due to an internal error.', $this->getContext($analysis));
     }
 }
Esempio n. 7
0
 /**
  * traitement réel du paiement
  *
  * @param  Ecedi\Donate\OgoneBundle\Ogone\Response $response
  * @return Payment                                 the payment instance
  */
 protected function doHandle(Response $response)
 {
     //initialize payment
     $payment = new Payment();
     $payment->setAutorisation($response->getAcceptance())->setTransaction($response->getPayId())->setResponseCode($response->getStatus())->setResponse($response);
     $normalizer = $this->container->get('donate_ogone.status_normalizer');
     $payment->setStatus($normalizer->normalize($response->getStatus()));
     try {
         //validate response
         $this->validate($response);
         $this->logger->debug('Payment Status : ' . $payment->getStatus());
     } catch (UnauthorizedPostSaleException $e) {
         $this->logger->warning('Incorrectly signed post-sale received');
         $payment->setStatus(Payment::STATUS_INVALID);
     }
     //add payment to intent
     try {
         $intentId = $this->getIntentId($response);
         $this->logger->debug('found intent id ' . $intentId);
     } catch (CannotDetermineOrderIdException $e) {
         $this->logger->warning('CannotDetermineOrderIdException');
         $intentId = false;
         //TODO le payment p-e ok, mais il est orphelin
     }
     $this->intentManager->attachPayment($intentId, $payment);
     return $payment;
 }
Esempio n. 8
0
 /**
  * @param Exception $e the Exception that was thrown
  * @param string $command the command that was being executed
  * @param array $args the arguments of the command
  * @throws \Plista\Core\Redis\Exception
  * @return bool
  */
 private function handleException(Exception $e, $command, $args)
 {
     $excBrief = "{$e->getCode()}: {$e->getMessage()} ({$e->getFile()}:{$e->getLine()}) Stacktrace:\n" . $e->getTraceAsString();
     //		$excHash = md5($excBrief);
     //		$curTime = Registry::getSystem()->getTime()->current();
     //
     //		$this->excLog[$excHash]['count']++;
     //		$this->excLog[$excHash]['time'] = $curTime;
     // log the exception
     $this->log->warning("Caught Redis exception: {$excBrief}");
     if ($this->exceptionHandler) {
         // notify the handler and get the strategy
         $context = ExceptionContext::fromFunctionAndArguments($command, $args);
         $strategy = $this->exceptionHandler->handleException($e, $context);
     } else {
         // use the default strategy
         $strategy = $this->defaultHandlerStrategy;
     }
     // default is to discard the exception
     if (!$strategy) {
         $strategy = ExceptionStrategy::DISCARD();
     }
     // let's see what the handler wants us to do
     if ($strategy->equals(ExceptionStrategy::RETHROW)) {
         throw $e;
     }
     // this case is used by the FailoverWrapper
     if ($strategy->equals(ExceptionStrategy::RETURN_VALUE)) {
         return $strategy->returnValue;
     }
     // return false to signal failure. maybe interpreted by some callers as a valid value (which it
     // is in some cases), but that's not for us to worry about.
     return false;
 }
 /**
  * {@inheritdoc}
  *
  * This method looks for a '_controller' request attribute that represents
  * the controller name (a string like ClassName::MethodName).
  *
  * @api
  */
 public function getController(Request $request)
 {
     if (!($controller = $request->attributes->get('_controller'))) {
         if (null !== $this->logger) {
             $this->logger->warning('Unable to look for the controller as the "_controller" parameter is missing');
         }
         return false;
     }
     if (is_array($controller)) {
         return $controller;
     }
     if (is_object($controller)) {
         if (method_exists($controller, '__invoke')) {
             return $controller;
         }
         throw new \InvalidArgumentException(sprintf('Controller "%s" for URI "%s" is not callable.', get_class($controller), $request->getPathInfo()));
     }
     if (false === strpos($controller, ':')) {
         if (method_exists($controller, '__invoke')) {
             return $this->app->make($controller);
         } elseif (function_exists($controller)) {
             return $controller;
         }
     }
     $callable = $this->createController($controller);
     if (!is_callable($callable)) {
         throw new \InvalidArgumentException(sprintf('Controller "%s" for URI "%s" is not callable.', $controller, $request->getPathInfo()));
     }
     return $callable;
 }
Esempio n. 10
0
 /**
  * @param \ErrorException $exception
  *
  * @return bool
  */
 protected function handleErrorException(\ErrorException $exception)
 {
     switch ($exception->getSeverity()) {
         case E_ERROR:
         case E_RECOVERABLE_ERROR:
         case E_CORE_ERROR:
         case E_COMPILE_ERROR:
         case E_USER_ERROR:
         case E_PARSE:
             $this->logger->error($this->buildLogMessage($exception));
             break;
         case E_WARNING:
         case E_USER_WARNING:
         case E_CORE_WARNING:
         case E_COMPILE_WARNING:
             $this->logger->warning($this->buildLogMessage($exception));
             break;
         case E_NOTICE:
         case E_USER_NOTICE:
             $this->logger->notice($this->buildLogMessage($exception));
             break;
         case E_STRICT:
         case E_DEPRECATED:
         case E_USER_DEPRECATED:
             $this->logger->info($this->buildLogMessage($exception));
             break;
     }
     return true;
 }
 /**
  * Returns parsed field value.
  *
  * @param \eZ\Publish\API\Repository\Values\Content\Content $content
  * @param string $field
  * @param string $language
  *
  * @return array
  */
 public function getFieldValue(Content $content, $field, $language)
 {
     $fieldObj = $content->getField($field, $language);
     $contentType = $this->contentTypeService->loadContentType($content->contentInfo->contentTypeId);
     $imageFieldIdentifier = $this->getImageFieldIdentifier($content->id, $language);
     $relatedContentId = $this->getRelation($content, $fieldObj->fieldDefIdentifier, $language);
     $mapping = $this->relationMapper->getMapping($contentType->identifier, $field);
     try {
         if ($relatedContentId && $mapping) {
             $relatedContent = $this->contentService->loadContent($relatedContentId);
             if ($relatedContent && $relatedContent->versionInfo->contentInfo->published) {
                 $relatedContentType = $this->contentTypeService->loadContentType($relatedContent->contentInfo->contentTypeId);
                 if ($relatedContentType->identifier != $mapping['content']) {
                     throw new InvalidRelationException(sprintf("Invalid relation: field '%s:%s' (object: %s, field: %s) has improper relation to object '%s' (object: %s) but '%s:%s' expected.", $contentType->identifier, $field, $content->id, $fieldObj->id, $relatedContentType->identifier, $relatedContentId, $mapping['content'], $mapping['field']));
                 }
                 $relatedField = $content->getField($mapping['field'], $language);
                 $value = $relatedField ? $this->getParsedFieldValue($relatedField, $relatedContent, $language, $imageFieldIdentifier) : '';
             } else {
                 $value = '';
             }
         } else {
             $value = $fieldObj ? $this->getParsedFieldValue($fieldObj, $content, $language, $imageFieldIdentifier) : '';
         }
     } catch (InvalidRelationException $exception) {
         $this->logger->warning($exception->getMessage());
         $value = '';
     }
     return array('key' => $field, 'value' => $value);
 }
Esempio n. 12
0
 /**
  * Returns the Controller instance associated with a Request.
  *
  * This method looks for a '_controller' request attribute that represents
  * the controller name (a string like ClassName::MethodName).
  *
  * @param Request $request A Request instance
  *
  * @return mixed|Boolean A PHP callable representing the Controller,
  *                       or false if this resolver is not able to determine the controller
  *
  * @throws \InvalidArgumentException|\LogicException If the controller can't be found
  *
  * @api
  */
 public function getController(\Symfony\Component\HttpFoundation\Request $request)
 {
     if (!($controller = $request->attributes->get('_controller'))) {
         if (null !== $this->logger) {
             $this->logger->warning('Unable to look for the controller as the "_controller" parameter is missing');
         }
         return false;
     }
     if (is_array($controller) || is_object($controller) && method_exists($controller, '__invoke')) {
         return $controller;
     }
     if (false === strpos($controller, ':')) {
         if (method_exists($controller, '__invoke')) {
             return new $controller();
         } elseif (function_exists($controller)) {
             return $controller;
         }
     }
     list($controller, $method) = $this->createController($controller);
     $this->parameters = array();
     if ($suffix = $request->attributes->get('_suffix')) {
         $parameters_temp = explode('/', $suffix);
         $parameters_temp = array_filter($parameters_temp, function ($el) {
             return $el !== '';
         });
         foreach ($parameters_temp as $p) {
             $this->parameters[] = $p;
         }
     }
     if ($method === '*') {
         if (count($this->parameters) > 0) {
             $method = array_shift($this->parameters);
         } elseif ($default_suffix = $request->attributes->get('_default_suffix')) {
             $method = $default_suffix;
         } else {
             $method = 'index';
         }
     }
     /** @var $controller ControllerInterface */
     $controller->setContext($this->context);
     $controller->setRequest($request);
     if (method_exists($controller, 'before')) {
         $controller->before($method);
     }
     if (method_exists($controller, 'security')) {
         if (!$controller->security()) {
             return array($controller, 'redirectToLogin');
         }
     }
     if (method_exists($controller, 'router')) {
         list($controller, $method, $this->parameters) = $controller->router($method, $this->parameters);
     } else {
         $method = 'action_' . $method;
     }
     if (!method_exists($controller, $method)) {
         throw new NotFoundHttpException();
         //throw new \InvalidArgumentException(sprintf('Method "%s::%s" does not exist.', get_class($controller), $method));
     }
     return array($controller, $method);
 }
Esempio n. 13
0
 /**
  * Performs the request to make the deployment
  *
  * @param string $description
  * @param bool $change
  * @param bool $user
  *
  * @return bool|string
  */
 public function setDeployment($description, $change = false, $user = false)
 {
     $apiUrl = $this->config->getNewRelicApiUrl();
     if (empty($apiUrl)) {
         $this->logger->notice('New Relic API URL is blank, using fallback URL');
         $apiUrl = self::API_URL;
     }
     /** @var \Magento\Framework\HTTP\ZendClient $client */
     $client = $this->clientFactory->create();
     $client->setUri($apiUrl);
     $client->setMethod(ZendClient::POST);
     $client->setHeaders(['x-api-key' => $this->config->getNewRelicApiKey()]);
     $params = ['deployment[app_name]' => $this->config->getNewRelicAppName(), 'deployment[application_id]' => $this->config->getNewRelicAppId(), 'deployment[description]' => $description, 'deployment[changelog]' => $change, 'deployment[user]' => $user];
     $client->setParameterPost($params);
     try {
         $response = $client->request();
     } catch (\Zend_Http_Client_Exception $e) {
         $this->logger->critical($e);
         return false;
     }
     if ($response->getStatus() < 200 || $response->getStatus() > 210) {
         $this->logger->warning('Deployment marker request did not send a 200 status code.');
         return false;
     }
     return $response->getBody();
 }
Esempio n. 14
0
 public function triggerWebtreesAdminTasks()
 {
     $settings = new Settings();
     $this->logger = \Piwik\Container\StaticContainer::get('Psr\\Log\\LoggerInterface');
     $this->logger->info('Webtrees Admin Task triggered');
     $rooturl = $settings->getSetting('webtreesRootUrl');
     if (!$rooturl || strlen($rooturl->getValue()) === 0) {
         return;
     }
     $token = $settings->getSetting('webtreesToken');
     if (!$token || strlen($token->getValue()) === 0) {
         return;
     }
     $taskname = $settings->getSetting('webtreesTaskName');
     if (!$taskname || strlen($taskname->getValue()) === 0) {
         return;
     }
     $url = sprintf('%1$s/module.php?mod=perso_admintasks&mod_action=trigger&force=%2$s&task=%3$s', $rooturl->getValue(), $token->getValue(), $taskname->getValue());
     $this->logger->info('webtrees url : {url}', array('url' => $url));
     try {
         \Piwik\Http::sendHttpRequest($url, Webtrees::SOCKET_TIMEOUT);
     } catch (Exception $e) {
         $this->logger->warning('an error occured', array('exception' => $e));
     }
 }
Esempio n. 15
0
 /**
  * Converts internal links (ezcontent:// and ezlocation://) to URLs.
  *
  * @param \DOMDocument $document
  *
  * @return \DOMDocument
  */
 public function convert(DOMDocument $document)
 {
     $document = clone $document;
     $xpath = new DOMXPath($document);
     $xpath->registerNamespace("docbook", "http://docbook.org/ns/docbook");
     $linkAttributeExpression = "starts-with( @xlink:href, 'ezlocation://' ) or starts-with( @xlink:href, 'ezcontent://' )";
     $xpathExpression = "//docbook:link[{$linkAttributeExpression}]|//docbook:ezlink";
     /** @var \DOMElement $link */
     foreach ($xpath->query($xpathExpression) as $link) {
         // Set resolved href to number character as a default if it can't be resolved
         $hrefResolved = "#";
         $href = $link->getAttribute("xlink:href");
         $location = null;
         preg_match("~^(.+://)?([^#]*)?(#.*|\\s*)?\$~", $href, $matches);
         list(, $scheme, $id, $fragment) = $matches;
         if ($scheme === "ezcontent://") {
             try {
                 $contentInfo = $this->contentService->loadContentInfo($id);
                 $location = $this->locationService->loadLocation($contentInfo->mainLocationId);
                 $hrefResolved = $this->urlAliasRouter->generate($location) . $fragment;
             } catch (APINotFoundException $e) {
                 if ($this->logger) {
                     $this->logger->warning("While generating links for richtext, could not locate " . "Content object with ID " . $id);
                 }
             } catch (APIUnauthorizedException $e) {
                 if ($this->logger) {
                     $this->logger->notice("While generating links for richtext, unauthorized to load " . "Content object with ID " . $id);
                 }
             }
         } else {
             if ($scheme === "ezlocation://") {
                 try {
                     $location = $this->locationService->loadLocation($id);
                     $hrefResolved = $this->urlAliasRouter->generate($location) . $fragment;
                 } catch (APINotFoundException $e) {
                     if ($this->logger) {
                         $this->logger->warning("While generating links for richtext, could not locate " . "Location with ID " . $id);
                     }
                 } catch (APIUnauthorizedException $e) {
                     if ($this->logger) {
                         $this->logger->notice("While generating links for richtext, unauthorized to load " . "Location with ID " . $id);
                     }
                 }
             } else {
                 $hrefResolved = $href;
             }
         }
         $hrefAttributeName = "xlink:href";
         // For embeds set the resolved href to the separate attribute
         // Original href needs to be preserved in order to generate link parameters
         // This will need to change with introduction of UrlService and removal of URL link
         // resolving in external storage
         if ($link->localName === "ezlink") {
             $hrefAttributeName = "href_resolved";
         }
         $link->setAttribute($hrefAttributeName, $hrefResolved);
     }
     return $document;
 }
Esempio n. 16
0
 /**
  * Converts a locale in POSIX format to eZ Publish internal format.
  * Returns null if conversion cannot be made.
  *
  * @param string $posixLocale
  *
  * @return string|null
  */
 public function convertToEz($posixLocale)
 {
     if (!isset($this->reverseConversionMap[$posixLocale])) {
         $this->logger->warning("Could not convert locale '{$posixLocale}' to eZ Publish format. Please check your locale configuration in ezpublish.yml");
         return;
     }
     return $this->reverseConversionMap[$posixLocale];
 }
Esempio n. 17
0
 /**
  * Set the currency classname
  *
  * @param  string $currency The iso-4217 currency code
  * @return void
  */
 public function setCurrencyClass(string $currency)
 {
     $currencyClassname = "byrokrat\\amount\\Currency\\{$currency}";
     if (!class_exists($currencyClassname)) {
         return $this->logger->warning("Unknown currency {$currency}");
     }
     $this->currencyClassname = $currencyClassname;
 }
Esempio n. 18
0
 /**
  *
  * {@inheritDoc}
  *
  * @see \Mcustiel\Phiremock\Server\Http\RequestHandler::execute()
  */
 public function execute(ServerRequestInterface $request, ResponseInterface $response)
 {
     try {
         return $this->router->start($request, $response);
     } catch (\Exception $e) {
         $this->logger->warning('Unexpected exception: ' . $e->getMessage());
         return $response->withStatus(500)->withBody(new StringStream($e->getMessage()));
     }
 }
 public function getController(Request $request)
 {
     if (!($controller = $request->attributes->get('_controller'))) {
         if (null !== $this->logger) {
             $this->logger->warning('Unable to look for the controller as the "_controller" parameter is missing');
         }
         return false;
     }
     return $this->createControllerInstance($controller, $request);
 }
 public function enterScope(NodeTraversal $traversal)
 {
     $typeInference = new TypeInference($traversal->getControlFlowGraph(), $this->reverseInterpreter, $this->functionInterpreter, $this->methodInterpreter, $this->commentParser, $traversal->getScope(), $this->registry, $this->logger);
     try {
         $typeInference->analyze();
     } catch (MaxIterationsExceededException $ex) {
         $scopeRoot = $traversal->getScopeRoot();
         $this->logger->warning($ex->getMessage() . ' - Scope-Root: ' . get_class($scopeRoot) . ' on line ' . $scopeRoot->getLine() . ' in ' . $this->file->getName());
     }
 }
Esempio n. 21
0
 /**
  * Delete an error
  *
  * @param int $code
  *
  * @return bool
  */
 public final function delete($code)
 {
     if (array_key_exists($code, $this->rpc_errors)) {
         unset($this->rpc_errors[$code]);
         $this->logger->info("Deleted error " . $code);
         return true;
     } else {
         $this->logger->warning("Cannot delete error " . $code . ": entry not found");
         return false;
     }
 }
Esempio n. 22
0
 /**
  * Delete a method
  *
  * @param string $name
  *
  * @return bool
  */
 public final function delete($name)
 {
     if (array_key_exists($name, $this->rpc_methods)) {
         unset($this->rpc_methods[$name]);
         $this->logger->info("Deleted method " . $name);
         return true;
     } else {
         $this->logger->warning("Cannot delete method " . $name . ": entry not found");
         return false;
     }
 }
Esempio n. 23
0
 /**
  * Delete a capability
  *
  * @param string $capability
  *
  * @return bool
  */
 public final function delete($capability)
 {
     if (array_key_exists($capability, $this->rpc_capabilities)) {
         unset($this->rpc_capabilities[$capability]);
         $this->logger->info("Deleted capability " . $capability);
         return true;
     } else {
         $this->logger->warning("Cannot delete capability " . $capability . ": entry not found");
         return false;
     }
 }
 /**
  * {@inheritdoc}
  */
 public function convert($source, $destination, Money $money)
 {
     try {
         return $this->crossRateConverter->convert($source, $destination, $money);
     } catch (CrossRateNotFoundException $e) {
         if ($this->logger) {
             $this->logger->warning(sprintf('Can not convert amount. Message: "%s". Try convert via simple currency.', rtrim($e->getMessage(), '.')));
         }
         return $this->currencyConverter->convert($source, $destination, $money);
     }
 }
 /**
  * {@inheritDoc}
  */
 public function loadUserByUsername($username)
 {
     try {
         $response = $this->facebook->get('/' . $username);
         return $response->getGraphNode(FacebookUser::class);
     } catch (FacebookResponseException $e) {
         $this->logger->info(sprintf('FacebookResponseException: %s', $e->getMessage()));
     } catch (FacebookSDKException $e) {
         $this->logger->warning(sprintf('FacebookSDKException: %s', $e->getMessage()));
     }
     throw new UsernameNotFoundException(sprintf('Username "%s" does not exist.', $username));
 }
Esempio n. 26
0
 public function fetchPageRank($domain)
 {
     $chwrite = $this->checkHash($this->hashURL($domain));
     $url = "http://toolbarqueries.google.com/tbr?client=navclient-auto&ch=" . $chwrite . "&features=Rank&q=info:" . $domain . "&num=100&filter=0";
     try {
         $response = Http::sendHttpRequest($url, $timeout = 10, @$_SERVER['HTTP_USER_AGENT']);
         preg_match('#Rank_[0-9]:[0-9]:([0-9]+){1,}#si', $response, $p);
         return isset($p[1]) ? $p[1] : null;
     } catch (\Exception $e) {
         $this->logger->warning('Error while getting Google PageRank for SEO stats: {message}', array('message' => $e->getMessage()));
         return null;
     }
 }
 /**
  * @test
  */
 public function handle_should_log_message_with_payload()
 {
     $exceptionMessage = "Fatal error";
     $baseException = new Exception($exceptionMessage);
     $payloadMessage = $this->prophesize(MessageInterface::class);
     $exception = new ConsumerContainerException($this->consumerContainer->reveal(), new AMQPMessage(), $payloadMessage->reveal(), $baseException);
     $this->handler->handle($exception);
     $this->logger->warning(Argument::allOf(Argument::containingString(self::MESSAGE_CLASS), Argument::containingString($exceptionMessage)), Argument::that(function ($context) use($baseException) {
         verify($context['exception'])->isInstanceOf(ConsumerContainerException::class);
         verify($context['exception']->getPrevious())->equals($baseException);
         return $context;
     }))->shouldHaveBeenCalled();
 }
 /**
  * Get template.
  *
  * @param FieldDescriptionInterface $fieldDescription
  * @param string                    $defaultTemplate
  *
  * @return \Twig_Template
  */
 protected function getTemplate(FieldDescriptionInterface $fieldDescription, $defaultTemplate, \Twig_Environment $environment)
 {
     $templateName = $fieldDescription->getTemplate() ?: $defaultTemplate;
     try {
         $template = $environment->loadTemplate($templateName);
     } catch (\Twig_Error_Loader $e) {
         $template = $environment->loadTemplate($defaultTemplate);
         if (null !== $this->logger) {
             $this->logger->warning(sprintf('An error occured trying to load the template "%s" for the field "%s", ' . 'the default template "%s" was used instead.', $templateName, $fieldDescription->getFieldName(), $defaultTemplate), array('exception' => $e));
         }
     }
     return $template;
 }
Esempio n. 29
0
 /**
  * {@inheritDoc}
  */
 public function process(Message $message, array $options)
 {
     $retry = 0;
     while ($retry++ < $options['instant_retry_attempts']) {
         try {
             return $this->processor->process($message, $options);
         } catch (\Exception $e) {
             $this->logger and $this->logger->warning(sprintf('[InstantRetry] An exception occurred. Message #%d will be processed again in %d ms', $message->getId(), $options['instant_retry_delay'] / 1000), array('swarrot_processor' => 'instant_retry', 'exception' => $e));
             usleep($options['instant_retry_delay']);
         }
     }
     throw $e;
 }
 /**
  * @param ConsoleTerminateEvent $event
  */
 public function onConsoleTerminate(ConsoleTerminateEvent $event)
 {
     $statusCode = $event->getExitCode();
     $command = $event->getCommand();
     if ($statusCode === 0) {
         return;
     }
     if ($statusCode > 255) {
         $statusCode = 255;
         $event->setExitCode($statusCode);
     }
     $this->logger->warning(sprintf('Command `%s` exited with status code %d', $command->getName(), $statusCode));
 }