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


PHP Logger::critical方法代码示例

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


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

示例1: process

 public function process(AMQPMessage $message)
 {
     $handlers = $this->logger->getHandlers();
     if (empty($handlers)) {
         throw new \Exception('No handlers registered');
     }
     $this->logger->critical($message->body);
     $message->delivery_info['channel']->basic_ack($message->delivery_info['delivery_tag']);
 }
开发者ID:sexlog,项目名称:monolog-telegram-handler,代码行数:9,代码来源:QueueConsumer.php

示例2: __invoke

 /**
  * @param Request $request
  * @param Response $response
  * @param \Exception $exception
  * @return Response
  */
 public function __invoke(Request $request, Response $response, \Exception $exception)
 {
     $logMessage = $exception->getMessage() . ' in ' . $exception->getFile() . ':' . $exception->getLine();
     // Log the message
     $this->logger->critical($logMessage);
     // create a JSON error string for the Response body
     $body = json_encode(['error' => $exception->getMessage(), 'code' => $exception->getCode()], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
     return $response->withStatus(500)->withHeader('Content-type', 'application/json')->write($body);
 }
开发者ID:AlexKR,项目名称:friendly,代码行数:15,代码来源:Error.php

示例3: testLogsLevelAndLevelName

 public function testLogsLevelAndLevelName()
 {
     $this->logger->debug('debug message');
     $this->logger->critical('critical message');
     $sql = 'SELECT * FROM logs WHERE level_name = \'%s\'';
     $debugLog = $this->pdo->query(sprintf($sql, 'DEBUG'))->fetch();
     $criticalLog = $this->pdo->query(sprintf($sql, 'CRITICAL'))->fetch();
     $this->assertNotEmpty($debugLog);
     $this->assertNotEmpty($criticalLog);
     $this->assertEquals($debugLog['message'], 'debug message');
     $this->assertEquals($criticalLog['message'], 'critical message');
 }
开发者ID:kafene,项目名称:monolog-pdo-handler,代码行数:12,代码来源:PdoHandlerTest.php

示例4: authenticate

 /**
  * Attempts to authenticate a TokenInterface object.
  *
  * @param TokenInterface $token The TokenInterface instance to authenticate
  *
  * @return TokenInterface An authenticated TokenInterface instance, never null
  *
  * @throws AuthenticationException if the authentication fails
  */
 public function authenticate(TokenInterface $token)
 {
     /** @var SignedTokenInterface $token */
     $user = $this->userProvider->loadUserByUsername($token->getUsername());
     $signData = $this->getAuthSignData($token->getRequest());
     $signData[] = $user->{$this->config['secret_getter']}();
     $expectedSignature = hash($this->config['hash_alg'], implode($this->config['data_delimiter'], $signData));
     if ($token->getSignature() == $expectedSignature) {
         $token->setUser($user);
         return $token;
     }
     $this->logger->critical(sprintf('Invalid auth signature. Expect "%s", got "%s"', $expectedSignature, $token->getSignature()), ['signData' => $signData]);
     throw new AuthenticationException("Invalid auth signature " . $token->getSignature());
 }
开发者ID:epustobaev,项目名称:signed-auth-bundle,代码行数:23,代码来源:SignedAuthProvider.php

示例5: critical

 public function critical($message, array $args = [], array $context = [])
 {
     if (count($args)) {
         $message = vsprintf($message, $args);
     }
     return parent::critical($message, $context);
 }
开发者ID:acgrid,项目名称:adbot,代码行数:7,代码来源:Logger.php

示例6: operate

 /**
  * @param $url
  * @param array $getData
  * @param array $postData
  * @param bool $addToken
  * @return mixed
  * @throws Exception
  */
 public function operate($url, array $getData = [], array $postData = [], $addToken = true)
 {
     if (!is_string($url)) {
         $this->logger->critical('$url doit être une chaîne de caractères.');
         if ($this->debug) {
             throw new Exception('$url doit être une chaîne de caractères.');
         }
     }
     if (!is_array($getData)) {
         $this->logger->critical('$getData doit être un tableau.');
         if ($this->debug) {
             throw new Exception('$getData doit être un tableau.');
         }
     }
     if (!is_array($postData)) {
         $this->logger->critical('$postData doit être un tableau.');
         if ($this->debug) {
             throw new Exception('$postData doit être un tableau.');
         }
     }
     $this->buildURL($url, $getData, $postData, $addToken);
     $ch = curl_init();
     curl_setopt_array($ch, array(CURLOPT_URL => $url, CURLOPT_RETURNTRANSFER => true, CURLINFO_HEADER_OUT => true, CURLOPT_HEADER => true));
     if ($this->getAuthBasicUser() && $this->getAuthBasicPass()) {
         curl_setopt($ch, CURLOPT_USERPWD, $this->getAuthBasicUser() . ":" . $this->getAuthBasicPass());
     }
     if (!empty($postData)) {
         curl_setopt_array($ch, array(CURLOPT_POST => true, CURLOPT_POSTFIELDS => json_encode($postData), CURLOPT_HTTPHEADER => array('Content-Type: application/json', 'Expect:')));
     }
     //        $res = explode("\r\n\r\n", curl_exec($ch));
     $response = new Response(curl_exec($ch));
     //        $data = json_decode($res[1], true);
     $data = $response->getData();
     $info = curl_getinfo($ch);
     $info = array('request' => array('url' => $info['url'], 'header' => curl_getinfo($ch, CURLINFO_HEADER_OUT), 'post_data' => json_encode($postData), 'content_type' => $info['content_type']), 'response' => array('header' => $response->headers->all(), 'http_code' => $info['http_code'], 'data' => $data));
     $this->lastRequest = $info['request'];
     $this->lastResponse = $info['response'];
     if ($info['response']['http_code'] != '200') {
         $message = isset($data['exception']['message']) ? $data['exception']['message'] : "CURL Request failed: " . $url;
         $code = isset($data['exception']['code']) ? $data['exception']['code'] : 0;
         $this->logger->critical($message);
         if ($this->debug) {
             //                dump($info);
             curl_close($ch);
             throw new Exception($message, $code);
         }
     }
     // Actuellement les contrôleurs s'attendent à ce que la propriété 'error' contienne le message d'erreur
     // et que la propriété 'code' contienne le code de l'exception.
     if (isset($data['exception'])) {
         if (!isset($data['error'])) {
             $data['error'] = $data['exception']['message'];
         }
         if (!isset($data['code'])) {
             $data['code'] = $data['exception']['code'];
         }
     }
     curl_close($ch);
     return $data;
 }
开发者ID:fidesio,项目名称:isidore-bundle,代码行数:68,代码来源:Client.php

示例7: callAsync

 protected function callAsync($function, array $data, $log = false)
 {
     if (strtolower($function) == 'login') {
         $this->wrapperLog->error('Login can not be called asynchronously!');
         throw new APIException('Login can not be called asynchronously!');
     }
     if (!empty($this->hash)) {
         $data['hash'] = $this->hash;
     }
     $socket = fsockopen(parse_url($this->apiAddress, PHP_URL_HOST), 80, $errno, $errstr);
     if ($socket === false) {
         $this->wrapperLog->critical('Error while opening asynchronous socket: ' . $errstr, array('code' => $errno));
         throw new ConnectionException('Error while opening asynchronous socket: ' . $errstr, $errno);
     }
     $data = 'data=' . urlencode(json_encode($data));
     $msg = 'POST /' . $this->qbankAddress . '/' . $function . ' HTTP/1.1' . "\r\n";
     $msg .= 'Host:' . parse_url($this->apiAddress, PHP_URL_HOST) . "\r\n";
     $msg .= 'Content-type: application/x-www-form-urlencoded' . "\r\n";
     $msg .= 'Content-length: ' . strlen($data) . "\r\n";
     $msg .= 'Connection: Close' . "\r\n\r\n";
     $msg .= $data;
     $result = fwrite($socket, $msg);
     if ($result === false) {
         $this->wrapperLog->critical('Error while writing to asycnhronous socket!');
         throw new ConnectionException('Error while writing to asycnhronous socket!');
     }
     @fclose($socket);
 }
开发者ID:kaigan,项目名称:qbankapi2wrapper,代码行数:28,代码来源:BaseAPI.php

示例8: testPushErrors

 /**
  *
  */
 public function testPushErrors()
 {
     $redis = \Mockery::mock('Predis\\Client')->shouldReceive('publish')->times(8)->with('log', \Mockery::any())->mock();
     $monolog = new Logger('test');
     $monolog->pushHandler(new PublishHandler(new RedisPublisher($redis)));
     $monolog->debug('the message was: {message}', ['DEBUG!']);
     $monolog->info('the message was: {message}', ['INFO!']);
     $monolog->notice('the message was: {message}', ['NOTICE!']);
     $monolog->warning('the message was: {message}', ['WARNING!']);
     $monolog->error('the message was: {message}', ['ERROR!']);
     $monolog->critical('the message was: {message}', ['CRITICAL!']);
     $monolog->alert('the message was: {message}', ['ALERT!']);
     $monolog->emergency('the message was: {message}', ['EMERGENCY!']);
 }
开发者ID:zae,项目名称:monolog-publish,代码行数:17,代码来源:RedisTest.php

示例9: testMonologPublishesMessageToKafkaBroker

 public function testMonologPublishesMessageToKafkaBroker()
 {
     $producerTopic = $this->buildProducerTopic();
     $handler = new KafkaHandler($producerTopic);
     $handler->setFormatter(new LineFormatter('%message%'));
     $monolog = new Logger('kafka-logger');
     $monolog->pushHandler($handler);
     $monolog->critical(self::MESSAGE);
     sleep(2);
     $consumerTopic = $this->buildConsumerTopic();
     $consumerTopic->consumeStart(self::PARTITION, rd_kafka_offset_tail(1));
     $message = $consumerTopic->consume(self::PARTITION, 1000);
     $consumerTopic->consumeStop(self::PARTITION);
     $this->assertEquals(self::MESSAGE, $message->payload);
 }
开发者ID:kwn,项目名称:monolog-kafka-handler,代码行数:15,代码来源:KafkaHandlerIntegrationTest.php

示例10: onKernelException

 /**
  * Respond to an exception with an error document wrapped in a Response.
  *
  * @param GetResponseForExceptionEvent $event
  */
 public function onKernelException(GetResponseForExceptionEvent $event)
 {
     $exception = $event->getException();
     // only intercept SwordController exceptions.
     if (!$this->controller[0] instanceof SwordController) {
         return;
     }
     if (!$exception instanceof SwordException) {
         return;
     }
     $this->logger->critical($exception->getMessage() . ' from ' . $this->requestStack->getCurrentRequest()->getClientIp());
     $response = $this->templating->renderResponse('AppBundle:Sword:error.xml.twig', array('error' => $exception));
     $response->headers->set('Content-Type', 'text/xml');
     $response->setStatusCode($exception->getStatusCode());
     $event->setResponse($response);
 }
开发者ID:ubermichael,项目名称:pkppln-php,代码行数:21,代码来源:SwordExceptionListener.php

示例11: critical

 /**
  * Critical conditions.
  *
  * Example: Application component unavailable, unexpected exception.
  *
  * @param string $message
  * @param array $context
  * @return null
  */
 public function critical($message, array $context = array())
 {
     $this->logger->critical($message, $context);
 }
开发者ID:tylercd100,项目名称:laravel-notify,代码行数:13,代码来源:Base.php

示例12: critical

 /**
  * Critical conditions.
  *
  * Example: Application component unavailable, unexpected exception.
  *
  * @param string $message
  * @param array $params
  * @param array $context
  * @return null
  */
 public function critical($message, array $params = array(), array $context = array())
 {
     $logMessage = $this->createMessage($message, $params);
     $this->logger->critical($logMessage, $context);
 }
开发者ID:rlacerda83,项目名称:laravel-dynamic-logger,代码行数:15,代码来源:DynamicLogger.php

示例13: __construct

 /**
  * Constructor method
  *
  * Prepare extender environment, do checks and fire extender.ready event
  */
 public final function __construct()
 {
     // check if extender is running from cli
     if (Checks::cli() === false) {
         echo "Extender runs only in php-cli, exiting";
         self::end(1);
     }
     // setup default timezone (in daemon mode, timezone warning may break extender)
     $default_timezone = ini_get('date.timezone');
     if (empty($default_timezone)) {
         date_default_timezone_set(defined('EXTENDER_TIMEZONE') ? EXTENDER_TIMEZONE : 'Europe/Rome');
     }
     $this->timestamp_absolute = microtime(true);
     $this->color = new Console_Color2();
     // get command line options (vsdh)
     list($this->verbose_mode, $this->debug_mode, $this->summary_mode, $this->daemon_mode, $help_mode) = self::getCommandlineOptions();
     if ($help_mode) {
         self::showHelp($this->color);
         self::end(0);
     }
     $this->logger = ExtenderLogger::create($this->verbose_mode, $this->debug_mode);
     // do checks
     $check_constants = Checks::constants();
     if ($check_constants !== true) {
         $this->logger->critical($check_constants);
         self::end(1);
     }
     if (Checks::signals() === false and $this->daemon_mode) {
         $this->logger->critical("Extender cannot run in daemon mode without PHP Process Control Extensions");
         self::end(1);
     }
     if (Checks::database() === false) {
         $this->logger->critical("Extender database not available, exiting");
         self::end(1);
     }
     $this->tasks = TasksTable::load($this->logger);
     $this->events = Events::load($this->logger);
     // setup extender parameters
     $this->max_result_bytes_in_multithread = defined('EXTENDER_MAX_RESULT_BYTES') ? filter_var(EXTENDER_MAX_RESULT_BYTES, FILTER_VALIDATE_INT) : 2048;
     $this->max_childs_runtime = defined('EXTENDER_MAX_CHILDS_RUNTIME') ? filter_var(EXTENDER_MAX_CHILDS_RUNTIME, FILTER_VALIDATE_INT) : 600;
     $this->multithread_mode = defined('EXTENDER_MULTITHREAD_ENABLED') ? filter_var(EXTENDER_MULTITHREAD_ENABLED, FILTER_VALIDATE_BOOLEAN) : false;
     // if in daemon mode, remember parent pid, setup lock and register signal handlers
     if ($this->daemon_mode) {
         $this->parent_pid = posix_getpid();
         Lock::register($this->parent_pid);
         $this->adjustNiceness();
         if (Checks::signals()) {
             $this->registerSignals();
         }
     }
     // init the runner
     $this->runner = new JobsRunner($this->logger, $this->getMultithreadMode(), $this->max_result_bytes_in_multithread, $this->max_childs_runtime);
     $this->logger->notice("Extender ready");
     // store initial status and queue information
     Status::dump($this->timestamp_absolute, $this->parent_pid, $this->completed_processes, $this->failed_processes, $this->paused);
     Queue::dump(0, 0);
     // we are ready to go!
 }
开发者ID:comodojo,项目名称:extender.framework,代码行数:63,代码来源:Extender.php

示例14: critical

 /**
  * @inheritdoc
  * @return boolean Whether the record has been processed.
  */
 public function critical($message, array $context = [])
 {
     return $this->_monolog->critical($message, $context);
 }
开发者ID:uniconstructor,项目名称:yii2-monolog,代码行数:8,代码来源:Logger.php

示例15: initAdapted

 public function initAdapted(\GearmanJob $job)
 {
     $this->loop = Factory::create();
     $this->read = new \React\Stream\Stream(STDIN, $this->loop);
     $this->read->bufferSize = 8192;
     $this->write = new \React\Stream\Stream(STDOUT, $this->loop);
     $this->write->bufferSize = 8192;
     $this->job = $job;
     //protect from repeated execution
     $initStart = false;
     $pmErrorDtoAlreadySent = false;
     /**
      * Receive sockets params json from PM to set it into performer
      */
     $this->read->on('data', function ($data) use($initStart, $pmErrorDtoAlreadySent) {
         if (!is_array($this->pmWorkerDta)) {
             $this->pmWorkerDta = @json_decode($data, true);
             if ($this->pmWorkerDta !== false && is_array($this->pmWorkerDta)) {
                 if ($initStart === false) {
                     $initStart = true;
                     try {
                         $this->initBasicParams();
                         $this->adaptedService->getTerminatorPauseStander()->setPublisherPmSocketAddress($this->pmWorkerDta[DataTransferConstants::PUBLISHER_PM]);
                         $this->adaptedService->getTerminatorPauseStander()->setUSleepTime(5000000);
                         $performerSocketParams = new PerformerSocketsParamsDto();
                         $performerSocketParams->setRequestPulsarRsSocketAddress($this->pmWorkerDta[DataTransferConstants::REQUEST_PULSAR_RS]);
                         $performerSocketParams->setPublisherPulsarSocketAddress($this->pmWorkerDta[DataTransferConstants::PUBLISHER_PULSAR]);
                         $performerSocketParams->setPushPulsarSocketAddress($this->pmWorkerDta[DataTransferConstants::PUSH_PULSAR]);
                         $this->adaptedService->getZmqPerformer()->setSocketsParams($performerSocketParams);
                         $this->adaptedService->getZmqPerformer()->setLogger($this->logger);
                         $this->adaptedService->serviceExec();
                         $this->adaptedService->getExecutionDto()->setExecutionMessage($this->adaptedService->getParams());
                         $this->job->sendComplete(serialize($this->adaptedService->getExecutionDto()));
                         $this->jobInfoWasSent = true;
                         $this->logger->critical("Job complete was sent.");
                     } catch (\Exception $e) {
                         $errorMsg = "Adapter die in Exception with \$e: " . $e->getMessage() . "|params: " . serialize($this->adaptedService->getParams());
                         //. $e->getTraceAsString();
                         $this->logger->critical($errorMsg . " | " . serialize($this->pmWorkerDta));
                         $this->job->sendComplete(serialize(InspectionHelper::prepareErrorExecutionDto($this->adaptedService->getTaskId(), $errorMsg)));
                         $this->jobInfoWasSent = true;
                         $this->logger->critical("Job complete with exception was sent.");
                         die;
                     }
                     $this->loop->nextTick(function () {
                         $this->loop->stop();
                     });
                 }
             } else {
                 if ($pmErrorDtoAlreadySent === false) {
                     $pmErrorDtoAlreadySent = true;
                     $pmErrorArr = [];
                     $pmErrorArr[DataTransferConstants::ERROR_LEVEL] = ErrorsConstants::CRITICAL;
                     $pmErrorArr[DataTransferConstants::ERROR_REASON] = PmErrorConstants::WORKER_NOT_RECEIVE_CORRECT_DTO;
                     $pmErrorArr[DataTransferConstants::ERROR_ELEMENT] = $this->pmWorkerDta;
                     //write to PM's allotted STDIN about critical error
                     $this->write->write(json_encode($pmErrorArr));
                     $this->loop->nextTick(function () {
                         $this->loop->stop();
                     });
                 }
             }
         }
     });
     $timerIteration = 0;
     $this->loop->addPeriodicTimer(3, function (Timer $timer) use(&$timerIteration) {
         if ($this->pmWorkerDta === null) {
             if ($timerIteration > $this->maxTimerIteration) {
                 $this->initBasicParams();
                 die;
             }
             $timerIteration++;
         } else {
             $timer->cancel();
         }
     });
     $this->loop->run();
     if ($pmErrorDtoAlreadySent) {
         die;
     }
 }
开发者ID:jamset,项目名称:gearman-conveyor,代码行数:81,代码来源:BaseAdapter.php


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