当前位置: 首页>>代码示例>>PHP>>正文


PHP Log\LoggerInterface类代码示例

本文整理汇总了PHP中Psr\Log\LoggerInterface的典型用法代码示例。如果您正苦于以下问题:PHP LoggerInterface类的具体用法?PHP LoggerInterface怎么用?PHP LoggerInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了LoggerInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: doExecute

 /**
  * @param LoggerInterface $logger
  * @param bool $dryRun
  */
 protected function doExecute(LoggerInterface $logger, $dryRun = false)
 {
     $duplicateEntitiesQuery = 'SELECT
             DISTINCT t2.id
         FROM
             orocrm_campaign_email_stats AS t1
         LEFT JOIN orocrm_campaign_email_stats AS t2
             ON t1.email_campaign_id = t2.email_campaign_id
             AND t1.marketing_list_item_id = t2.marketing_list_item_id
             AND t2.id > t1.id
         WHERE t2.id IS NOT NULL';
     // Done in 2 queries for cross DB support.
     $idsToRemove = array_map(function ($item) {
         if (is_array($item) && array_key_exists('id', $item)) {
             return $item['id'];
         }
         return null;
     }, $this->connection->fetchAll($duplicateEntitiesQuery));
     if ($idsToRemove) {
         $query = 'DELETE FROM orocrm_campaign_email_stats WHERE id IN (?)';
         $logger->notice($query);
         if (!$dryRun) {
             $this->connection->executeQuery($query, [$idsToRemove], [Connection::PARAM_INT_ARRAY]);
         }
     }
 }
开发者ID:antrampa,项目名称:crm,代码行数:30,代码来源:AggregateStatisticsQuery.php

示例2: __invoke

 public function __invoke(Request $req, Response $res, callable $next)
 {
     $res = $next($req, $res);
     $identity = $this->authService->getIdentity();
     if (!$identity) {
         return $res;
     }
     try {
         $user = R::findOne('user', 'mail = ?', [$identity->mail]);
         if (!$user) {
             $user = R::dispense('user');
             $user->uid = $identity->uid;
             $user->mail = $identity->mail;
             $user->display_name = $identity->displayName;
             $user->office_name = $identity->officeName;
             $user->authentication_source = $identity->authenticationSource;
             $user->password = '';
             $user->created = time();
             $user->role = 'school';
             $this->logger->info(sprintf('User %s imported from sso.sch.gr to database', $identity->mail));
         }
         $user->last_login = time();
         $user_id = R::store($user);
         $identityClass = get_class($identity);
         $newIdentity = new $identityClass($user_id, $user->uid, $user->mail, $user->display_name, $user->office_name, $user->authentication_source);
         $this->authService->getStorage()->write($newIdentity);
     } catch (\Exception $e) {
         $this->authService->clearIdentity();
         $this->flash->addMessage('danger', 'A problem occured storing user in database. <a href="%s" title="SSO logout">SSO Logout</a>');
         $this->logger->error('Problem inserting user form CAS in database', $identity->toArray());
         $this->logger->debug('Exception', [$e->getMessage(), $e->getTraceAsString()]);
         return $res->withRedirect($this->userErrorRedirectUrl);
     }
     return $res;
 }
开发者ID:eellak,项目名称:gredu_labs,代码行数:35,代码来源:CreateUser.php

示例3: errorLog

 /**
  * logs failed request api call including options and error message
  *
  * @param string $scope
  * @param string $name
  * @param array $opts
  * @param string $message
  * @return boolean
  */
 public function errorLog($scope, $name, $opts, $message)
 {
     // stop measure the response time
     $this->stop();
     $this->logger->error(sprintf('failed: %s to %s (%2.4fs), message: %s', Config::getInstance()->http_post ? 'POST' : 'GET', $this->formatUrl($scope, $name, $opts), $this->responseTime, $message));
     return true;
 }
开发者ID:addrever,项目名称:ecat,代码行数:16,代码来源:PsrLogger.php

示例4: consumeJob

 /**
  * Dispatches messages to the job manager.
  *
  * This method is registered as the message handler for messages with name "ConsumeJob".
  *
  * @param DefaultMessage $message
  */
 public function consumeJob(DefaultMessage $message)
 {
     $ticket = $message->ticket;
     $type = $message->type;
     $this->logger->debug('Consume message from bernard backend', ['message' => $message]);
     $this->manager->onMessage(new Message($type, $ticket));
 }
开发者ID:aboutcoders,项目名称:job-bundle,代码行数:14,代码来源:ProducerAdapter.php

示例5: setPid

 /**
  * @param string $pid
  */
 public function setPid($pid)
 {
     if (null !== $this->logger) {
         $this->logger->debug("Started GearmanWorker Daemon {$pid}");
     }
     file_put_contents($this->getPidFile(), $pid);
 }
开发者ID:micmorozov,项目名称:yii2-gearman,代码行数:10,代码来源:Process.php

示例6: render

 /**
  * {@inheritdoc}
  */
 public function render(BlockContextInterface $blockContext, Response $response = null)
 {
     $block = $blockContext->getBlock();
     if ($this->logger) {
         $this->logger->info(sprintf('[cms::renderBlock] block.id=%d, block.type=%s ', $block->getId(), $block->getType()));
     }
     try {
         $service = $this->blockServiceManager->get($block);
         $service->load($block);
         $response = $service->execute($blockContext, $this->createResponse($blockContext, $response));
         if (!$response instanceof Response) {
             $response = null;
             throw new \RuntimeException('A block service must return a Response object');
         }
         $response = $this->addMetaInformation($response, $blockContext, $service);
     } catch (\Exception $exception) {
         if ($this->logger) {
             $this->logger->critical(sprintf('[cms::renderBlock] block.id=%d - error while rendering block - %s', $block->getId(), $exception->getMessage()));
         }
         // reseting the state object
         $this->lastResponse = null;
         $response = $this->exceptionStrategyManager->handleException($exception, $blockContext->getBlock(), $response);
     }
     return $response;
 }
开发者ID:karousn,项目名称:SonataBlockBundle,代码行数:28,代码来源:BlockRenderer.php

示例7: getController

 /**
  * Detects if there is a custom controller to use to render a Block.
  *
  * @param FilterControllerEvent $event
  *
  * @throws \Symfony\Component\Security\Core\Exception\AccessDeniedException
  */
 public function getController(FilterControllerEvent $event)
 {
     $request = $event->getRequest();
     // Only taking page related controller (i.e. ez_page:viewBlock or ez_page:viewBlockById)
     if (strpos($request->attributes->get('_controller'), 'ez_page:') === false) {
         return;
     }
     try {
         if ($request->attributes->has('id')) {
             $valueObject = $this->pageService->loadBlock($request->attributes->get('id'));
             $request->attributes->set('block', $valueObject);
         } elseif ($request->attributes->get('block') instanceof Block) {
             $valueObject = $request->attributes->get('block');
             $request->attributes->set('id', $valueObject->id);
         }
     } catch (UnauthorizedException $e) {
         throw new AccessDeniedException();
     }
     if (!isset($valueObject)) {
         $this->logger->error('Could not resolve a page controller, invalid value object to match.');
         return;
     }
     $controllerReference = $this->controllerManager->getControllerReference($valueObject, 'block');
     if (!$controllerReference instanceof ControllerReference) {
         return;
     }
     $request->attributes->set('_controller', $controllerReference->controller);
     $event->setController($this->controllerResolver->getController($request));
 }
开发者ID:xcorp1986,项目名称:ezpublish-kernel,代码行数:36,代码来源:PageControllerListener.php

示例8: filter

 public function filter($tempMinifiedFilename)
 {
     $originalFilename = $this->srcFile->getPath();
     $jarPath = $this->externalLibPath . '/closurecompiler/compiler.jar';
     $command = "java -jar {$jarPath} --warning_level QUIET --language_in ECMASCRIPT5 --compilation_level SIMPLE_OPTIMIZATIONS --js {$originalFilename} --js_output_file {$tempMinifiedFilename}";
     //SIMPLE_OPTIMIZATIONS
     //ADVANCED_OPTIMIZATIONS
     //java -jar compiler.jar --compilation_level ADVANCED_OPTIMIZATIONS --js hello.js
     $output = system($command, $returnValue);
     if ($returnValue != 0) {
         @unlink($tempMinifiedFilename);
         $logging = "command is {$command} <br/>";
         $logging .= "curr dir " . getcwd() . "<br/>";
         $logging .= "returnValue {$returnValue} <br/>";
         $logging .= "result is: ";
         $logging .= "Output is: " . $output . "<br/>";
         $this->logger->critical("Failed to generate minified Javascript: " . $logging);
         header("Content-type: text/javascript");
         header("Cache-Control: no-cache, must-revalidate");
         // HTTP/1.1
         header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
         // Date in the past
         echo "alert('Javacript not generated. Someone please tell the server dude \"{$originalFilename}\" failed.')";
         exit(0);
     }
 }
开发者ID:finelinePG,项目名称:imagick,代码行数:26,代码来源:ClosureCompilerFilter.php

示例9: testBeforeDispatchWithException

 public function testBeforeDispatchWithException()
 {
     $exception = new LocalizedException(new Phrase('Phrase'));
     $this->themeRegistration->expects($this->once())->method('register')->willThrowException($exception);
     $this->logger->expects($this->once())->method('critical');
     $this->plugin->beforeDispatch($this->abstractAction, $this->request);
 }
开发者ID:koliaGI,项目名称:magento2,代码行数:7,代码来源:RegistrationTest.php

示例10: handleException

 /**
  * Handle exception
  *
  * @param \Exception $e
  * @return void
  */
 protected function handleException($e)
 {
     $needToMaskDisplayMessage = !$e instanceof \Magento\Framework\Exception\LocalizedException && $this->appState->getMode() != State::MODE_DEVELOPER;
     $displayMessage = $needToMaskDisplayMessage ? (string) new \Magento\Framework\Phrase('An error occurred while processing your request') : $e->getMessage();
     $this->messageManager->addError($displayMessage);
     $this->logger->critical($e->getMessage());
 }
开发者ID:opexsw,项目名称:magento2,代码行数:13,代码来源:FrontController.php

示例11: debug

 /**
  * Logs payment related information used for debug
  *
  * @param array $debugData
  * @param array $debugReplaceKeys
  * @param bool $debugFlag
  * @return void
  */
 public function debug(array $debugData, array $debugReplaceKeys, $debugFlag)
 {
     if ($debugFlag == true && !empty($debugData) && !empty($debugReplaceKeys)) {
         $debugData = $this->filterDebugData($debugData, $debugReplaceKeys);
         $this->logger->debug(var_export($debugData, true));
     }
 }
开发者ID:kid17,项目名称:magento2,代码行数:15,代码来源:Logger.php

示例12: afterRead

 /**
  * @param \Magento\Framework\HTTP\Adapter\Curl $subject
  * @param $result
  * @return mixed
  */
 public function afterRead(\Magento\Framework\HTTP\Adapter\Curl $subject, $result)
 {
     try {
         /* @var $curlLog \Foggyline\Sentinel\Model\CurlLog */
         $curlLog = $this->curlLog->create();
         $curlLog->setRequestId($this->helper->getHttpRequestUniqueId());
         $curlLog->setResult($result);
         $curlLog->setMethod($this->cUrlMethod);
         $curlLog->setUrl($this->cUrlUrl);
         $curlLog->setHttpVer($this->cUrlHttpVer);
         $curlLog->setHeaders(serialize($this->cUrlHeaders));
         $curlLog->setBody($this->cUrlBody);
         $curlLog->setHttpCode($subject->getInfo(CURLINFO_HTTP_CODE));
         $curlLog->setTotalTime($subject->getInfo(CURLINFO_TOTAL_TIME));
         $curlLog->setNameLookupTime($subject->getInfo(CURLINFO_NAMELOOKUP_TIME));
         $curlLog->setPrimaryIp($subject->getInfo(CURLINFO_PRIMARY_IP));
         $curlLog->setPrimaryPort($subject->getInfo(CURLINFO_PRIMARY_PORT));
         $curlLog->setLocalIp($subject->getInfo(CURLINFO_LOCAL_IP));
         $curlLog->setLocalPort($subject->getInfo(CURLINFO_LOCAL_PORT));
         $curlLog->setSizeUpload($subject->getInfo(CURLINFO_SIZE_UPLOAD));
         $curlLog->setSizeDownload($subject->getInfo(CURLINFO_SIZE_DOWNLOAD));
         $curlLog->setSpeedUpload($subject->getInfo(CURLINFO_SPEED_UPLOAD));
         $curlLog->setSpeedDownload($subject->getInfo(CURLINFO_SPEED_DOWNLOAD));
         $curlLog->setContentType($subject->getInfo(CURLINFO_CONTENT_TYPE));
         $curlLog->save();
     } catch (\Exception $e) {
         $this->logger->critical($e);
     }
     return $result;
 }
开发者ID:ajzele,项目名称:Foggyline_Sentinel,代码行数:35,代码来源:CurlPlugin.php

示例13: onKernelController

 public function onKernelController(FilterControllerEvent $event)
 {
     if (!$this->isTrackingEnabled) {
         return;
     }
     $controller = $event->getController();
     /*
      * $controller passed can be either a class or a Closure.
      * This is not usual in Symfony but it may happen.
      * If it is a class, it comes in array format
      * @link http://symfony.com/doc/current/event_dispatcher/before_after_filters.html#creating-an-event-listener
      */
     if (!is_array($controller)) {
         return;
     }
     $controller = $controller[0];
     if ($controller instanceof Controller) {
         $request = $event->getRequest();
         $path = $request->getRequestUri();
         $host = $request->getHost();
         $title = get_class($controller);
         $data = ['dh' => $host, 'dp' => $path, 'dt' => $title];
         try {
             $this->tracker->send($data, 'pageview');
         } catch (\Exception $e) {
             $this->logger->error('Failed to send tracking data.', ['exception' => $e]);
         }
     }
 }
开发者ID:stopfstedt,项目名称:ilios,代码行数:29,代码来源:TrackApiUsageListener.php

示例14: consume

 /**
  * consume.
  *
  * @param array $options Parameters sent to the processor
  */
 public function consume(array $options = array())
 {
     if (null !== $this->logger) {
         $this->logger->debug(sprintf('Start consuming queue %s.', $this->messageProvider->getQueueName()));
     }
     $this->optionsResolver->setDefaults(array('poll_interval' => 50000));
     if ($this->processor instanceof ConfigurableInterface) {
         $this->processor->setDefaultOptions($this->optionsResolver);
     }
     $options = $this->optionsResolver->resolve($options);
     if ($this->processor instanceof InitializableInterface) {
         $this->processor->initialize($options);
     }
     while (true) {
         while (null !== ($message = $this->messageProvider->get())) {
             if (false === $this->processor->process($message, $options)) {
                 break 2;
             }
         }
         if ($this->processor instanceof SleepyInterface) {
             if (false === $this->processor->sleep($options)) {
                 break;
             }
         }
         usleep($options['poll_interval']);
     }
     if ($this->processor instanceof TerminableInterface) {
         $this->processor->terminate($options);
     }
 }
开发者ID:kyar,项目名称:swarrot,代码行数:35,代码来源:Consumer.php

示例15: process

 /**
  * @param Message $message
  */
 public function process(Message $message)
 {
     // Only process messages where ShareMonkey is mentioned
     if ($this->shareMonkeyIsMentioned($message->getText()) === false) {
         return;
     }
     $text = $message->getText();
     $urls = $text->getUrls();
     $tags = $text->getTags();
     if (count($urls) === 0) {
         $this->logger->debug('No urls found in message');
         return;
     }
     $user = $this->userRepository->findOneBySlackId($message->getUserId());
     if (!$user instanceof User) {
         $this->logger->error(sprintf('User "%s" not found', $message->getUserId()->getValue()));
         return;
     }
     foreach ($urls as $url) {
         $this->logger->debug(sprintf('processing url %s', $url));
         $info = Embed::create($url);
         $link = Link::fromSlack($message->getId(), $user, $message->getCreatedAt(), $info->getTitle() ?: $message->getText(), $url, $tags);
         $this->objectManager->persist($link);
         $this->objectManager->flush();
         $this->objectManager->clear();
         $this->logger->debug(sprintf('Saved link %s', $link->getUrl()));
     }
 }
开发者ID:vincecore,项目名称:sharemonkey,代码行数:31,代码来源:IncomingLinkProcessor.php


注:本文中的Psr\Log\LoggerInterface类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。