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


PHP LoggerInterface::error方法代码示例

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


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

示例1: __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

示例2: 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

示例3: onKernelException

 /**
  * @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));
 }
开发者ID:krizon,项目名称:swagger-bundle,代码行数:35,代码来源:ExceptionListener.php

示例4: switchLocaleAction

 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);
 }
开发者ID:OpenConext,项目名称:OpenConext-profile,代码行数:25,代码来源:LocaleController.php

示例5: login

 /**
  * Authenticate a user from shibboleth
  *
  * If the user is not yet logged in send a redirect Request
  * If the user is logged in, but no account exists send an error
  * If the user is authenticated send a JWT
  * @param Request $request
  *
  * @throws \Exception when the shibboleth attributes do not contain a value for the configured user id attribute
  * @return JsonResponse
  */
 public function login(Request $request)
 {
     $applicationId = $request->server->get('Shib-Application-ID');
     if (!$applicationId) {
         return new JsonResponse(array('status' => 'redirect', 'errors' => [], 'jwt' => null), JsonResponse::HTTP_OK);
     }
     $userId = $request->server->get($this->userIdAttribute);
     if (!$userId) {
         $msg = "No '{$this->userIdAttribute}' found for authenticated user.";
         $logVars = [];
         $shibProperties = ['Shib-Session-ID', 'Shib-Authentication-Instant', 'Shib-Authentication-Method', 'Shib-Session-Index'];
         foreach ($shibProperties as $key) {
             $logVars[$key] = $request->server->get($key);
         }
         $logVars['HTTP_REFERER'] = $request->server->get('HTTP_REFERER');
         $logVars['REMOTE_ADDR'] = $request->server->get('REMOTE_ADDR');
         $this->logger->error($msg, ['server variables' => var_export($logVars, true)]);
         throw new \Exception($msg);
     }
     /* @var \Ilios\CoreBundle\Entity\AuthenticationInterface $authEntity */
     $authEntity = $this->authManager->findOneBy(array('username' => $userId));
     if ($authEntity) {
         $user = $authEntity->getUser();
         if ($user->isEnabled()) {
             $jwt = $this->jwtManager->createJwtFromUser($user);
             return $this->createSuccessResponseFromJWT($jwt);
         }
     }
     return new JsonResponse(array('status' => 'noAccountExists', 'userId' => $userId, 'errors' => [], 'jwt' => null), JsonResponse::HTTP_OK);
 }
开发者ID:stopfstedt,项目名称:ilios,代码行数:41,代码来源:ShibbolethAuthentication.php

示例6: loadMessages

 /**
  * Load messages from message directory.
  */
 protected function loadMessages()
 {
     if ($this->messages === null) {
         $this->messages = array();
         foreach (glob("{$this->messageDirectory}/*.json") as $file) {
             $lang = strtolower(substr(basename($file), 0, -5));
             if ($lang === 'qqq') {
                 // Ignore message documentation
                 continue;
             }
             if (is_readable($file)) {
                 $json = file_get_contents($file);
                 if ($json === false) {
                     $this->logger->error('Error reading file', array('method' => __METHOD__, 'file' => $file));
                     continue;
                 }
                 $data = json_decode($json, true);
                 if ($data === null) {
                     $this->logger->error('Error parsing json', array('method' => __METHOD__, 'file' => $file, 'json_error' => json_last_error()));
                     continue;
                 }
                 // Discard metadata
                 unset($data['@metadata']);
                 if (empty($data)) {
                     // Ignore empty languages
                     continue;
                 }
                 $this->messages[$lang] = $data;
             }
         }
     }
 }
开发者ID:felixonmars,项目名称:simplei18n,代码行数:35,代码来源:JsonCache.php

示例7: 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

示例8: handleErrorException

 /**
  * @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;
 }
开发者ID:phprest,项目名称:phprest,代码行数:34,代码来源:Log.php

示例9: run

 /**
  * Run the daemon.
  *
  * @return int
  */
 public function run()
 {
     $this->logger->info("Status: starting up.");
     while (true) {
         $this->taskPersist->begin();
         $tasks = $this->tasksFinder->findDueTasks();
         foreach ($tasks as $task) {
             try {
                 $handlerClass = $task->getHandlerClass();
                 /** @var TaskHandlerInterface $handler */
                 $handler = new $handlerClass(...$task->getArguments());
                 $this->decorate($handler);
                 $this->logger->info("Handle {$handlerClass}");
                 $handler->handle();
                 if ($task->isReoccurring()) {
                     $task->reoccur();
                     $this->taskPersist->persist($task);
                 } else {
                     $this->taskPersist->remove($task);
                 }
             } catch (Exception $e) {
                 $this->logger->error("{$e->getMessage()}\n{$e->getTraceAsString()}");
                 $task->setDisabled();
                 $this->taskPersist->persist($task);
             }
         }
         $this->taskPersist->commit();
         sleep(1);
     }
 }
开发者ID:messyOne,项目名称:Daemon,代码行数:35,代码来源:Daemon.php

示例10: send

 /**
  * @param  string $email
  * @param  string $message_id
  * @return string
  */
 public function send($email, $message_id)
 {
     $message = $this->saml_data_manager->get($message_id);
     if (!$message) {
         if ($this->logger) {
             $this->logger->error("Saml message with id {$message_id} not found or expired");
         }
         throw new RuntimeException('Authentication message does not exist');
     }
     $this->saml_data_manager->delete($message_id);
     $response = new Response();
     $assertion = new Assertion();
     $response->addAssertion($assertion)->setID(Helper::generateID())->setIssueInstant(new DateTime())->setDestination($message->getAssertionConsumerServiceURL())->setIssuer(new Issuer($message->getIssuer()->getValue()));
     $assertion->setId(Helper::generateID())->setIssueInstant(new DateTime())->setIssuer(new Issuer($message->getIssuer()->getValue()))->setSubject((new Subject())->setNameID(new NameID($email, SamlConstants::NAME_ID_FORMAT_EMAIL))->addSubjectConfirmation((new SubjectConfirmation())->setMethod(SamlConstants::CONFIRMATION_METHOD_BEARER)->setSubjectConfirmationData((new SubjectConfirmationData())->setInResponseTo($message->getID())->setNotOnOrAfter(new DateTime('+1 MINUTE'))->setRecipient($message->getAssertionConsumerServiceURL()))))->setConditions((new Conditions())->setNotBefore(new DateTime())->setNotOnOrAfter(new DateTime('+1 MINUTE'))->addItem(new AudienceRestriction([$message->getAssertionConsumerServiceURL()])))->addItem((new AttributeStatement())->addAttribute(new Attribute(ClaimTypes::EMAIL_ADDRESS, $email)))->addItem((new AuthnStatement())->setAuthnInstant(new DateTime('-10 MINUTE'))->setSessionIndex($message_id)->setAuthnContext((new AuthnContext())->setAuthnContextClassRef(SamlConstants::AUTHN_CONTEXT_PASSWORD_PROTECTED_TRANSPORT)));
     $certificate = X509Certificate::fromFile($this->saml_crt);
     $private_key = KeyHelper::createPrivateKey($this->saml_key, '', true);
     $response->setSignature(new SignatureWriter($certificate, $private_key));
     $binding_factory = new BindingFactory();
     $post_binding = $binding_factory->create(SamlConstants::BINDING_SAML2_HTTP_POST);
     $message_context = new MessageContext();
     $message_context->setMessage($response);
     /** @var SymfonyResponse $http_response */
     $http_response = $post_binding->send($message_context);
     return $http_response->getContent();
 }
开发者ID:activecollab,项目名称:authentication,代码行数:30,代码来源:SsoResponse.php

示例11: onKernelException

 /**
  * @param GetResponseForExceptionEvent $event
  */
 public function onKernelException(GetResponseForExceptionEvent $event)
 {
     $exception = $event->getException();
     if ($exception instanceof ExternalApiException) {
         $this->logger->error($exception->getMessage());
     }
 }
开发者ID:CampaignChain,项目名称:core,代码行数:10,代码来源:ExternalExceptionListener.php

示例12: register

 public static function register(LoggerInterface $logger)
 {
     register_shutdown_function(function () use($logger) {
         $errfile = "unknown file";
         $errstr = "shutdown";
         $errno = E_CORE_ERROR;
         $errline = 0;
         $error = error_get_last();
         if ($error !== NULL) {
             $errno = $error["type"];
             $errfile = $error["file"];
             $errline = $error["line"];
             $errstr = $error["message"];
         }
         $message = sprintf('Fatal error: %s at %s line %s', $errstr, $errfile, $errline);
         $logger->critical($message);
     });
     set_error_handler(function ($errno, $errstr, $errfile, $errline) use($logger) {
         $message = sprintf('Error: %s at %s line %s', $errstr, $errfile, $errline);
         $logger->error($message);
         echo "{$message}\n";
     });
     set_exception_handler(function (\Exception $e) use($logger) {
         $message = sprintf('%s: %s (uncaught exception) at %s line %s', get_class($e), $e->getMessage(), $e->getFile(), $e->getLine());
         $logger->error($message);
         echo "{$message}\n";
     });
 }
开发者ID:elfchat,项目名称:elfchat,代码行数:28,代码来源:ErrorLogger.php

示例13: error

 /**
  * 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;
         }
     }
 }
开发者ID:sinergi,项目名称:core,代码行数:43,代码来源:ErrorHandler.php

示例14: send

 /**
  * @param string $request
  *
  * @throws \Ndm\JsonRpc2\Client\Exception\TransportException
  * @throws \Ndm\JsonRpc2\Client\Exception\HttpTransportException
  *
  * @return string
  */
 public function send($request)
 {
     $defaults = array('method' => 'POST', 'header' => array('Content-Type: application/json', 'Connection: close'), 'content' => $request, 'protocol_version' => 1.0, 'ignore_errors' => true);
     $options = $this->getContextOptions($defaults);
     $this->logger->info('Sending Request', array('url' => $this->url, 'context_options' => $options));
     // create the context
     $context = stream_context_create($options);
     // connect and open the stream
     $stream = fopen($this->url, 'r', false, $context);
     // get the response headers etc.
     $headers = stream_get_meta_data($stream);
     // actual data at $url
     $content = stream_get_contents($stream);
     fclose($stream);
     $this->logger->info('Received Reply', array('headers' => $headers, 'content' => $content));
     if (!isset($headers['wrapper_data'])) {
         throw new Exception\TransportException("Failed to connect to URL {$this->url}");
     }
     // check the status code of the response
     list($successful, $statusCode, $statusMessage) = $this->checkStatus($headers['wrapper_data']);
     if (!$successful) {
         $this->logger->error('Request was not successful', array('url' => $this->url, 'context_options' => $options, 'headers' => $headers, 'content' => $content));
         throw new Exception\HttpTransportException($statusCode, $statusMessage, $content);
     }
     return $content;
 }
开发者ID:nathan-muir,项目名称:json-rpc-2,代码行数:34,代码来源:HttpStreamTransport.php

示例15: fire

 /**
  * @param Job $syncJob Laravel queue job
  * @param $arguments
  * @return bool
  * @throws \Unifact\Connector\Exceptions\HandlerException
  */
 public function fire(Job $syncJob, $arguments)
 {
     try {
         $job = $this->jobRepo->findById($arguments['job_id']);
         $job->setPreviousStatus($arguments['previous_status']);
         $handler = forward_static_call([$job->handler, 'make']);
         $this->logger->debug("Preparing Job..");
         if (!$handler->prepare()) {
             $this->logger->error('Handler returned FALSE in prepare() method, see log for details');
             // delete Laravel queue job
             $syncJob->delete();
             return false;
         }
         $this->logger->debug("Handling Job..");
         if ($handler->handle($job) === false) {
             $this->logger->error('Handler returned FALSE in handle() method, see log for details');
             // delete Laravel queue job
             $syncJob->delete();
             return false;
         }
         $this->logger->debug("Completing Job..");
         $handler->complete();
         $this->logger->info('Finished Job successfully');
     } catch (\Exception $e) {
         $this->oracle->exception($e);
         $this->logger->error('Exception was thrown in JobQueueHandler::fire method.');
         $this->jobRepo->update($arguments['job_id'], ['status' => 'error']);
         // delete Laravel queue job
         $syncJob->delete();
         return false;
     }
     // delete Laravel queue job
     $syncJob->delete();
     return true;
 }
开发者ID:unifact,项目名称:connector,代码行数:41,代码来源:JobQueueHandler.php


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