notice() public method

Normal but significant events.
public notice ( string $message, array $context = [] ) : null
$message string
$context array
return null
示例#1
0
 /**
  * Error handler
  *
  * @param $errno
  * @param $errstr
  * @param $errfile
  * @param $errline
  */
 public function error($errno, $errstr, $errfile, $errline)
 {
     $message = $errstr . ' in ' . $errfile . ' on line ' . $errline;
     if (null !== $this->logger) {
         switch ($errno) {
             case E_CORE_ERROR:
             case E_COMPILE_ERROR:
             case E_COMPILE_WARNING:
                 $this->logger->emergency($message);
                 break;
             case E_ERROR:
             case E_USER_ERROR:
             case E_PARSE:
             case E_RECOVERABLE_ERROR:
                 $this->logger->error($message);
                 break;
             case E_WARNING:
             case E_USER_WARNING:
                 $this->logger->warning($message);
                 break;
             case E_NOTICE:
             case E_USER_NOTICE:
                 $this->logger->notice($message);
                 break;
             case E_DEPRECATED:
             case E_USER_DEPRECATED:
             case E_STRICT:
                 $this->logger->notice($message);
                 break;
             default:
                 $this->logger->error("Unknown error type: " . $errno . ": " . $message);
                 break;
         }
     }
 }
 /**
  * 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));
     }
 }
 public function switchLocaleAction(Request $request)
 {
     $this->guard->userIsLoggedIn();
     $this->logger->notice('User requested to switch locale');
     $returnUrl = $request->query->get('return-url');
     // Return URLs generated by us always include a path (ie. at least a forward slash)
     // @see https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpFoundation/Request.php#L878
     $domain = $request->getSchemeAndHttpHost() . '/';
     if (strpos($returnUrl, $domain) !== 0) {
         $this->logger->error(sprintf('Illegal return-url ("%s") for redirection after changing locale, aborting request', $returnUrl));
         throw new BadRequestHttpException('Invalid return-url given');
     }
     $command = new ChangeLocaleCommand();
     $form = $this->formFactory->create('profile_switch_locale', $command, [])->handleRequest($request);
     $this->logger->notice(sprintf('Switching locale from "%s" to "%s"', $request->getLocale(), $command->newLocale));
     if ($form->isValid()) {
         $this->userService->changeLocale($command);
         $this->flashBag->add('success', 'profile.locale.locale_change_success');
         $this->logger->notice(sprintf('Successfully switched locale from "%s" to "%s"', $request->getLocale(), $command->newLocale));
     } else {
         $this->flashBag->add('error', 'profile.locale.locale_change_fail');
         $this->logger->error('Locale not switched: the switch locale form contained invalid data');
     }
     return new RedirectResponse($returnUrl);
 }
 /**
  * @param GetResponseForExceptionEvent $event
  */
 public function onKernelException(GetResponseForExceptionEvent $event)
 {
     $logRef = uniqid();
     $exception = $event->getException();
     if ($exception instanceof NotFoundHttpException) {
         $event->setResponse(new VndErrorResponse("Not found", Response::HTTP_NOT_FOUND));
         return;
     }
     if ($exception instanceof AuthenticationException) {
         $event->setResponse(new VndErrorResponse("Unauthorized", Response::HTTP_UNAUTHORIZED));
         return;
     }
     new VndErrorResponse("Authentication Failure", Response::HTTP_UNAUTHORIZED);
     $code = $exception->getCode();
     if (strlen($code) !== 3) {
         $this->fallback($message, $code, $logRef, $exception);
     } else {
         switch (substr($code, 0, 1)) {
             case '4':
                 $message = 'Input Error';
                 $this->logger->notice("Input error [logref {$logRef}]: " . $exception->__toString());
                 break;
             case '5':
                 $message = 'Server Error';
                 $this->logger->error("Runtime error [logref {$logRef}]: " . $exception->__toString());
                 break;
             default:
                 $this->fallback($message, $code, $logRef, $exception);
         }
     }
     $event->setResponse(new VndErrorResponse($message, $code, $logRef));
 }
 /**
  * @param VerifyYubikeyPublicIdCommand $command
  * @return VerificationResult
  */
 public function verifyYubikeyPublicId(VerifyYubikeyPublicIdCommand $command)
 {
     $verifyOtpCommand = new VerifyYubikeyOtpCommand();
     $verifyOtpCommand->otp = $command->otp;
     $verifyOtpCommand->identityId = $command->identityId;
     $verifyOtpCommand->institution = $command->institution;
     $verificationResult = $this->yubikeyService->verify($verifyOtpCommand);
     if (YubikeyOtp::isValid($command->otp)) {
         $otp = YubikeyOtp::fromString($command->otp);
         $publicId = YubikeyPublicId::fromOtp($otp);
     } else {
         $publicId = null;
     }
     if ($verificationResult->isServerError()) {
         return new VerificationResult(VerificationResult::RESULT_OTP_VERIFICATION_FAILED, $publicId);
     } elseif ($verificationResult->isClientError()) {
         return new VerificationResult(VerificationResult::RESULT_OTP_INVALID, $publicId);
     }
     if ($publicId->getYubikeyPublicId() !== $command->expectedPublicId) {
         $this->logger->notice('Yubikey used by registrant during vetting did not match the one used during registration.');
         return new VerificationResult(VerificationResult::RESULT_PUBLIC_ID_DID_NOT_MATCH, $publicId);
     }
     $this->logger->info('Yubikey used by registrant during vetting matches the one used during registration.');
     return new VerificationResult(VerificationResult::RESULT_PUBLIC_ID_MATCHED, $publicId);
 }
示例#6
0
 private function fetchGitTemplate($gitUrl)
 {
     $this->logger->notice('Fetching template from {url}', ['url' => $gitUrl]);
     $directory = $this->createTempDirectory('couscous_template_');
     $this->git->cloneRepository($gitUrl, $directory);
     return $directory;
 }
 /**
  * {@inheritdoc}
  */
 public function handle(ServerRequestInterface $request, $exception)
 {
     if ($exception instanceof HttpException) {
         if ($this->logger) {
             $this->logger->notice($this->prettifyRequest($request));
             $this->logger->notice($exception);
         }
         return $exception;
     }
     if ($this->config->get('debug', true)) {
         $whoops = $this->getWhoops($request);
         return create($whoops->handleException($exception), 500);
     }
     $statusCode = 500;
     $reasonPhrase = 'Internal Server Error';
     if ($exception instanceof RouteNotFoundException) {
         $statusCode = 404;
         $reasonPhrase = "Not Found";
     } elseif ($exception instanceof RouteMethodException) {
         $statusCode = 405;
         $reasonPhrase = 'Method Not Allowed';
     }
     if ($this->logger) {
         $this->logger->error($this->prettifyRequest($request));
         $this->logger->error($exception);
     }
     if ($this->isAjax($request)) {
         return json(['status' => $statusCode, 'reason' => $reasonPhrase], $statusCode);
     }
     return create("{$statusCode} {$reasonPhrase}", $statusCode);
 }
 /**
  * @return Response
  */
 public function overviewAction()
 {
     $this->guard->userIsLoggedIn();
     $this->logger->notice('Showing My Profile page');
     $user = $this->userService->getUser();
     return new Response($this->templateEngine->render('OpenConextProfileBundle:MyProfile:overview.html.twig', ['user' => $user]));
 }
 /**
  * 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();
 }
示例#10
0
文件: Log.php 项目: phprest/phprest
 /**
  * @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;
 }
示例#11
0
 /**
  * @param ClassMetadataInfo $metadata
  * @param bool              $force
  */
 protected function loadEntityConfigs(ClassMetadataInfo $metadata, $force)
 {
     if ($this->hasEntityConfigs($metadata)) {
         $className = $metadata->getName();
         if ($this->configManager->hasConfig($className)) {
             $this->logger->notice(sprintf('Update config for "%s" entity.', $className));
             $this->configManager->updateConfigEntityModel($className, $force);
         } else {
             $this->logger->notice(sprintf('Create config for "%s" entity.', $className));
             $this->configManager->createConfigEntityModel($className);
         }
         $fieldNames = $metadata->getFieldNames();
         foreach ($fieldNames as $fieldName) {
             if ($this->hasFieldConfigs($metadata, $fieldName)) {
                 $fieldType = $metadata->getTypeOfField($fieldName);
                 $this->loadFieldConfigs($className, $fieldName, $fieldType, $force);
             }
         }
         $associationNames = $metadata->getAssociationNames();
         foreach ($associationNames as $associationName) {
             if ($this->hasAssociationConfigs($metadata, $associationName)) {
                 $associationType = $metadata->isSingleValuedAssociation($associationName) ? 'ref-one' : 'ref-many';
                 $this->loadFieldConfigs($className, $associationName, $associationType, $force);
             }
         }
     }
 }
示例#12
0
 /**
  * @param LoggerInterface $logger
  * @param null            $outputDir
  */
 public function generate(LoggerInterface $logger, $outputDir = null)
 {
     $logger->notice('Generate started');
     if (!is_null($outputDir)) {
         $logger->notice('Cleaning dir.');
         $outputDir = realpath($outputDir) . '/';
         foreach (glob($outputDir . '*') as $file) {
             unlink($file);
         }
     }
     foreach ($this->handlers as $handler) {
         $handlerName = basename(str_replace(['\\', 'Handler'], '/', get_class($handler)));
         $logger->notice(sprintf('Generating %s', $handlerName));
         foreach ($handler->getRecords() as $record) {
             $config = $handler->buildConfig($record);
             if (is_null($outputDir)) {
                 echo $config->prettyPrint(-1);
             } else {
                 $fileName = $handlerName . '-' . $this->createFilename($record);
                 $this->write($fileName, $config, $outputDir);
                 $logger->debug(sprintf('%s as %s', $record->getNode()->getTitle(), $fileName));
             }
         }
     }
     $logger->notice('Generate ended');
 }
 /**
  * Method to run a domain job whose workload is a serialized JobRequestInterface
  *
  * @param \GearmanJob $job Object with job parameters
  *
  * @throws \Ice\Domain\Jobs\UnsupportedJobException
  * @throws \Exception re-throw uncaught exceptions
  * @return boolean
  *
  * @Gearman\Job(
  *     iterations = 1,
  *     name = "addDomainJob",
  *     description = "Data should be an json-encoded object containing at least a 'name' property. That domain job wll be executed"
  * )
  */
 public function addDomainJob($job)
 {
     $jobRequest = $this->requestSerializer->deserializeJobRequest($job->workload());
     if ($this->logger) {
         $this->logger->notice("Job received", [$job->workload()]);
     }
     if (!$this->director->hasWorkerProviderFor($jobRequest->getName())) {
         if ($this->logger) {
             $this->logger->critical("No worker available for job of name: " . $jobRequest->getName(), [$job->workload()]);
         }
         throw new UnsupportedJobException("No worker available for job of name: " . $jobRequest->getName());
     }
     $worker = $this->director->getWorkerProviderFor($jobRequest->getName())->getWorkerFor($jobRequest->getName());
     try {
         if ($this->eventDispatcher) {
             $this->eventDispatcher->dispatch('ice.job.pre_execute');
         }
         $worker->execute($jobRequest);
         if ($this->logger) {
             $this->logger->notice("Job complete", [$job->workload()]);
         }
     } catch (\Exception $e) {
         if ($this->logger) {
             $this->logger->critical("Uncaught exception when processing job", array('workload' => $job->workload(), 'message' => $e->getMessage(), 'stack_trace' => $e->getTrace(), 'exception' => $e));
         }
         //Re-throw the exception anyway, so that gearman knows the job has failed.
         throw $e;
     }
     return true;
 }
示例#14
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);
         }
     }
 }
示例#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;
 }
 public function onKernelTerminate()
 {
     $requestTime = $this->getExecutionTime();
     $queryTime = $this->queryExecution->getTotalTime();
     $queryCount = $this->queryExecution->getCount();
     $memory = $this->getMemoryUsage();
     $this->logger->notice(sprintf('Resources: request time = %sms; query time = %sms;' . ' query count = %s; memory = %sMB', $requestTime, $queryTime, $queryCount, $memory), ['metadata' => ['request_time' => $requestTime, 'request_time_unit' => 'ms', 'query_total_time' => $queryTime, 'query_total_time_unit' => 'ms', 'query_count' => $queryCount, 'memory_usage' => $memory, 'memory_usage_unit' => 'MB'], 'description' => 'resource']);
 }
 /**
  * Gets a list of email addresses which have an owner
  * Email addresses are sorted by modification date; newest at the top
  *
  * @return EmailAddress[]
  */
 protected function getKnownEmailAddresses()
 {
     $this->log->notice('Loading known email addresses ...');
     $repo = $this->emailAddressManager->getEmailAddressRepository($this->em);
     $query = $repo->createQueryBuilder('a')->select('partial a.{id, email, updated}')->where('a.hasOwner = ?1')->orderBy('a.updated', 'DESC')->setParameter(1, true)->getQuery();
     $emailAddresses = $query->getResult();
     $this->log->notice(sprintf('Loaded %d email address(es).', count($emailAddresses)));
     return $emailAddresses;
 }
 /**
  * Tests sending a mail to two recipients.
  *
  * @covers ::execute
  */
 public function testSendMailToTwoRecipients()
 {
     $to = ['*****@*****.**', '*****@*****.**'];
     $this->action->setContextValue('to', $to)->setContextValue('subject', 'subject')->setContextValue('message', 'hello');
     $params = ['subject' => 'subject', 'message' => 'hello'];
     $this->mailManager->mail('rules', 'rules_action_mail_' . $this->action->getPluginId(), implode(', ', $to), LanguageInterface::LANGCODE_SITE_DEFAULT, $params, NULL)->willReturn(['result' => TRUE])->shouldBeCalledTimes(1);
     $this->logger->notice(Argument::any(), Argument::any())->shouldBeCalledTimes(1);
     $this->action->execute();
 }
 public function overviewAction()
 {
     $this->guard->userIsLoggedIn();
     $this->logger->notice('User requested My Services page');
     $user = $this->authenticatedUserProvider->getCurrentUser();
     $specifiedConsentList = $this->specifiedConsentListService->getListFor($user);
     $this->logger->notice(sprintf('Showing %s services on My Services page', count($specifiedConsentList)));
     return new Response($this->templateEngine->render('OpenConextProfileBundle:MyServices:overview.html.twig', ['specifiedConsentList' => $specifiedConsentList]));
 }
示例#20
0
 private function executeScript($sourceDirectory, $script)
 {
     $script = 'cd "' . $sourceDirectory . '" && ' . $script;
     $this->logger->notice('Executing {script}', ['script' => $script]);
     try {
         $this->commandRunner->run($script);
     } catch (CommandException $e) {
         throw new \RuntimeException("Error while running '{$script}':" . PHP_EOL . $e->getMessage());
     }
 }
 /**
  * @param ConsoleExceptionEvent $event
  */
 public function onConsoleException(ConsoleExceptionEvent $event)
 {
     $command = $event->getCommand();
     $exception = $event->getException();
     // Log error with trace
     $trace = MAUTIC_ENV == 'dev' ? "\n[stack trace]\n" . $exception->getTraceAsString() : '';
     $message = sprintf('%s: %s (uncaught exception) at %s line %s while running console command `%s`%s', get_class($exception), $exception->getMessage(), $exception->getFile(), $exception->getLine(), $command->getName(), $trace);
     // Use notice so it makes it to the log all "perttified" (using error spits it out to console and not the log)
     $this->logger->notice($message);
 }
示例#22
0
 /**
  * Performs the match against the Controller.
  * 
  * @param \Micro\Request $request
  * @param \Micro\ControllerInterface $controller
  * @return boolean
  */
 public function match(Request $request, ControllerInterface $controller)
 {
     foreach ($this->matchers as $matcher) {
         if (!$matcher->match($request, $controller)) {
             $this->tracer->notice("Matching failed on {$matcher->name()} check");
             return false;
         }
     }
     return true;
 }
示例#23
0
 function it_can_sleep(LoggerInterface $logger)
 {
     file_put_contents("sleep", "1");
     $logger->notice(Argument::containingString("1 seconds worth of work"))->shouldBeCalled();
     $logger->notice(Argument::containingString("Succeeding"))->shouldBeCalled();
     $this->sleeper = function () {
         return 1;
     };
     $this->perform();
 }
示例#24
0
 /**
  * Transport class is responsible for dispatching requests to the
  * underlying cluster connections
  *
  * @param $retries
  * @param bool $sniffOnStart
  * @param ConnectionPool\AbstractConnectionPool $connectionPool
  * @param \Psr\Log\LoggerInterface $log    Monolog logger object
  */
 public function __construct($retries, $sniffOnStart = false, AbstractConnectionPool $connectionPool, LoggerInterface $log)
 {
     $this->log = $log;
     $this->connectionPool = $connectionPool;
     $this->retries = $retries;
     if ($sniffOnStart === true) {
         $this->log->notice('Sniff on Start.');
         $this->connectionPool->scheduleCheck();
     }
 }
示例#25
0
 /**
  * Handle the error by pushing it to logger.
  */
 public function handle()
 {
     $e = $this->getException();
     // HTTP Exceptions should just be notices, not criticals.
     if ($e instanceof HTTPExceptionInterface) {
         $this->logger->notice('Got HTTP exception {code}: "{message}" from {class} in file {file} on line {line}.' . NL . 'Trace: ' . NL . '{trace}', array('code' => $e->getCode(), 'class' => get_class($e), 'message' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine(), 'trace' => $e->getTraceAsString()));
         return Handler::DONE;
     }
     $this->logger->critical('{class}: {message} in file {file} on line {line}.' . NL . 'Trace: ' . NL . '{trace}', array('class' => get_class($e), 'message' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine(), 'trace' => $e->getTraceAsString(), '@stat' => 'splot.exception'));
     return Handler::DONE;
 }
 /**
  * Adds a query to a log
  *
  * @param LoggerInterface $logger
  * @param string          $query
  * @param array           $params
  * @param array           $types
  */
 protected function logQuery(LoggerInterface $logger, $query, array $params = [], array $types = [])
 {
     $logger->notice($query);
     if (!empty($params)) {
         $resolvedParams = $this->resolveParams($params, $types);
         $logger->notice('Parameters:');
         foreach ($resolvedParams as $key => $val) {
             $logger->notice(sprintf('[%s] = %s', $key, $val));
         }
     }
 }
示例#27
0
 public function __invoke(Project $project)
 {
     if ($project->regenerate || !$this->hasBowerJson($project)) {
         return;
     }
     $this->logger->notice('Executing "bower install"');
     $result = $this->commandRunner->run(sprintf('cd "%s" && bower install', $project->metadata['template.directory']));
     if ($result) {
         $this->logger->info($result);
     }
 }
示例#28
0
 /**
  * @param array $fileList
  */
 public function delete(array $fileList)
 {
     foreach ($fileList as $file) {
         $this->logger->notice('Deleting ' . $file . ' in s3 bucket ' . $this->filesystem->getAdapter()->getBucket());
         try {
             $this->filesystem->delete($file);
         } catch (\Exception $e) {
             $this->logger->error('Exception while deleting ' . $file . ': ' . $e->getMessage());
         }
     }
 }
示例#29
0
 public function send(RequestInterface $request, MessageInterface $response, array $options = array())
 {
     try {
         parent::send($request, $response, $options);
     } catch (RuntimeException $e) {
         // Catch but do not do anything as we consider the request to be ~ asynchronous
         if (isset($this->logger)) {
             $this->logger->notice("An issue occurred while handling HttpCache purge: {$e->getMessage()}.");
         }
     }
 }
示例#30
0
 /**
  * Logs information about the processed item
  *
  * @param ItemEvent $event
  */
 public function onItemProcessed(ItemEvent $event)
 {
     if ($event instanceof SuccessItemEvent) {
         $this->logger->info(sprintf('<info>✔</info> <comment>%s</comment>', (string) $event->getItem()));
     }
     if ($event instanceof FailedItemEvent) {
         $this->logger->error(sprintf('<fg=red;options=bold>✘</> <comment>%s</comment>  <fg=red>failed: %s</>', (string) $event->getItem(), $event->getReason()));
     }
     if ($event instanceof SkippedItemEvent) {
         $this->logger->notice(sprintf('<options=bold>#</> <comment>%s</comment>  skipped: %s', (string) $event->getItem(), $event->getReason()));
     }
 }