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


PHP Logger::warn方法代码示例

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


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

示例1: process

 /**
  * Gets a message from RabbitMQ, checks it's a valid transaction and saves it into DB.
  *
  * @param AMQPMessage $rawMessage
  */
 public function process(AMQPMessage $rawMessage)
 {
     $this->logger->debug('Processing message ' . $rawMessage->body);
     try {
         $message = Transaction::extractFromJson($rawMessage->body);
         $message->checkSanity();
         $this->messageDbModel->save($message);
     } catch (Exception $e) {
         // either transaction contains invalid data or there was an error in db
         $this->logger->warn($e->getMessage());
     }
 }
开发者ID:picahielos,项目名称:mtp,代码行数:17,代码来源:MessageProcessor.php

示例2: processMessage

 protected function processMessage(QueueMessage $message)
 {
     $msg = null;
     if (isset($message->getBody()->Message)) {
         $msg = json_decode($message->getBody()->Message);
     }
     $this->logger->debug("Processing kill message", ['message' => $msg]);
     if ($msg != null) {
         $jobId = $msg->jobId;
         /** @var Job $job */
         $job = $this->elasticsearch->getJob($jobId);
         if (!is_null($job)) {
             if ($job->getProcess()['host'] == gethostname()) {
                 if ($job->getStatus() == Job::STATUS_WAITING) {
                     $job->setStatus(Job::STATUS_CANCELLED);
                     $job->setResult(['message' => 'Job cancelled by user']);
                     $this->getComponentJobMapper($job->getComponent())->update($job);
                     $this->logger->info("receive-kill: Job '{$jobId}' cancelled", ['job' => $job->getData()]);
                     $this->requeue($job->getId());
                 } else {
                     if ($job->getStatus() == Job::STATUS_PROCESSING) {
                         $job->setStatus(Job::STATUS_TERMINATING);
                         $this->getComponentJobMapper($job->getComponent())->update($job);
                         $pid = $job->getProcess()['pid'];
                         // kill child processes
                         $process = new Process('
                         function getcpid() {
                                     cpids=`pgrep -P $1|xargs`
                             for cpid in $cpids;
                             do
                                 echo "$cpid"
                                 getcpid $cpid
                             done
                         }
                         getcpid ' . $pid);
                         $process->run();
                         $processes = $process->getOutput();
                         if ($processes && count(explode("\n", $processes))) {
                             foreach (explode("\n", $processes) as $child) {
                                 if ($child != '') {
                                     (new Process("sudo kill -KILL {$child}"))->run();
                                 }
                             }
                         }
                         // kill parent process
                         posix_kill($pid, SIGKILL);
                         $this->logger->info("receive-kill: Job '{$jobId}' killed", ['job' => $job->getData()]);
                     } else {
                         $this->logger->info("receive-kill: Job is not in waiting or processing state", ['job' => $job->getData()]);
                     }
                 }
             }
         }
     } else {
         $this->logger->warn("Corrupted message received", ['message' => $message]);
     }
     $this->queue->deleteMessage($message);
 }
开发者ID:keboola,项目名称:syrup-queue,代码行数:58,代码来源:ReceiveKillCommand.php

示例3: send

 /**
  * @param $message
  * @param $users
  * @param null $extra
  * @return bool|int     Return TRUE if all users get messages, otherwise number of user not received message
  */
 public function send($message, $users, $extra = null, $badge = 0)
 {
     if (!is_array($users)) {
         $users = [$users];
     }
     $sentNum = 0;
     foreach ($users as $user) {
         $devices = $this->pushDeviceService->findDevicesByUser($user);
         $atLeastOneSent = false;
         if (count($devices) > 0) {
             foreach ($devices as $device) {
                 // TODO: save to DB sent notifications
                 if ($device->isiOS()) {
                     if ($this->container->has('push_apns.service')) {
                         $res = $this->container->get('push_apns.service')->push($message, $device, $extra, $badge);
                         $devicesToLog = $device->getDeviceToken();
                         if (true === $res) {
                             $this->logger->info('Message: ' . $message . ', was sent to device#: ' . $devicesToLog, ['PushNotification']);
                             $atLeastOneSent = true;
                         } else {
                             $this->logger->warn('Error occurred while sending message: ' . $message . ', to device#: ' . $devicesToLog, ['PushNotification']);
                         }
                     } else {
                         $this->logger->error('Notification cannot be send as service push_apns.service is not available', ['PushNotification']);
                     }
                 } elseif ($device->isAndroidOS()) {
                     // TODO: TBD
                 }
             }
         } else {
             $this->logger->warn('User #' . $user . ' has no registered devices', ['PushNotification']);
         }
         if ($atLeastOneSent) {
             ++$sentNum;
         }
     }
     if (count($users) == $sentNum) {
         return true;
     } else {
         return count($users) - $sentNum;
     }
 }
开发者ID:nnmer,项目名称:push-notification-bundle,代码行数:48,代码来源:PushNotificationService.php

示例4: paymentResponse

 /**
  * @param array $parameters
  * @return bool
  */
 public function paymentResponse(array $parameters)
 {
     $paymentResponse = new EcommercePaymentResponse($parameters);
     $passphrase = $this->shaOut;
     $shaComposer = new AllParametersShaComposer($passphrase);
     $shaComposer->addParameterFilter(new ShaOutParameterFilter());
     //optional
     if ($paymentResponse->isValid($shaComposer) && $paymentResponse->isSuccessful()) {
         $event = new OgoneEvent($parameters);
         $this->eventDispatcher->dispatch(OgoneEvents::SUCCESS, $event);
         // handle payment confirmation
         $this->logger->info('Ogone payment success');
         return true;
     } else {
         $event = new OgoneEvent($parameters);
         $this->eventDispatcher->dispatch(OgoneEvents::ERROR, $event);
         $this->logger->warn('Ogone payment failure', $parameters);
     }
     return false;
 }
开发者ID:jmsche,项目名称:SnowcapOgoneBundle,代码行数:24,代码来源:OgoneManager.php

示例5: detectIllegalStateChanges

 private function detectIllegalStateChanges()
 {
     if (null !== $this->aggregateIdentifier && null !== $this->workingAggregate && $this->reportIllegalStateChange) {
         $uow = DefaultUnitOfWork::startAndGet();
         try {
             $aggregate2 = $this->repository->load($this->aggregateIdentifier);
             if ($this->workingAggregate->isDeleted()) {
                 throw new GovernorAssertionError("The working aggregate was considered deleted, " . "but the Repository still contains a non-deleted copy of " . "the aggregate. Make sure the aggregate explicitly marks " . "itself as deleted in an EventHandler.");
             }
             $this->assertValidWorkingAggregateState($aggregate2);
         } catch (AggregateNotFoundException $notFound) {
             if (!$this->workingAggregate->isDeleted()) {
                 throw new GovernorAssertionError("The working aggregate was not considered deleted, " . "but the Repository cannot recover the state of the " . "aggregate, as it is considered deleted there.");
             }
         } catch (\Exception $ex) {
             $this->logger->warn("An Exception occurred while detecting illegal state changes in {class}.", array('class' => get_class($this->workingAggregate)), $ex);
         } finally {
             // rollback to prevent changes bing pushed to event store
             $uow->rollback();
         }
     }
 }
开发者ID:fcm,项目名称:GovernorFramework,代码行数:22,代码来源:GivenWhenThenTestFixture.php

示例6: failed

 /**
  * Implements failing tables; if an account type fails multiple times,
  * then send the user an email and disable the account.
  * @see OpenclerkJobQueuer#getStandardJobs()
  */
 function failed(\Exception $runtime_exception, Connection $db, Logger $logger)
 {
     // is this a standard job?
     $standard = $this->findStandardJob();
     if ($standard) {
         $logger->info("Using standard job " . print_r($standard, true));
         if (!$standard['failure']) {
             $logger->info("Not a failure standard job");
             return;
         }
     } else {
         return;
     }
     $failing_table = $standard['table'];
     $job = $this->job;
     // find the relevant account_data for this standard job
     $account_data = false;
     foreach (account_data_grouped() as $label => $group) {
         foreach ($group as $exchange => $data) {
             if (isset($data['job_type']) && $job['job_type'] == $data['job_type']) {
                 $account_data = $data;
                 $account_data['exchange'] = $exchange;
                 break;
             }
         }
     }
     if (!$account_data) {
         $logger->warn("Could not find any account data for job type '" . $job['job_type'] . "'");
     }
     $logger->info("Using account data " . print_r($account_data, true));
     // don't count CloudFlare as a failure
     if ($runtime_exception instanceof CloudFlareException || $runtime_exception instanceof \Openclerk\Apis\CloudFlareException) {
         $logger->info("Not increasing failure count: was a CloudFlareException");
     } else {
         if ($runtime_exception instanceof IncapsulaException || $runtime_exception instanceof \Openclerk\Apis\IncapsulaException) {
             $logger->info("Not increasing failure count: was a IncapsulaException");
         } else {
             if ($runtime_exception instanceof BlockchainException || $runtime_exception instanceof \Core\BlockchainException) {
                 $logger->info("Not increasing failure count: was a BlockchainException");
             } else {
                 $q = $db->prepare("UPDATE {$failing_table} SET failures=failures+1,first_failure=IF(ISNULL(first_failure), NOW(), first_failure) WHERE id=?");
                 $q->execute(array($job['arg_id']));
                 $logger->info("Increasing account failure count");
             }
         }
     }
     $user = get_user($job['user_id']);
     if (!$user) {
         $logger->info("Warning: No user " . $job['user_id'] . " found");
     } else {
         // failed too many times?
         $q = $db->prepare("SELECT * FROM {$failing_table} WHERE id=? LIMIT 1");
         $q->execute(array($job['arg_id']));
         $account = $q->fetch();
         $logger->info("Current account failure count: " . number_format($account['failures']));
         if ($account['failures'] >= get_premium_value($user, 'max_failures')) {
             // disable it and send an email
             $q = $db->prepare("UPDATE {$failing_table} SET is_disabled=1 WHERE id=?");
             $q->execute(array($job['arg_id']));
             crypto_log(print_r($account_data, true));
             if ($user['email'] && !$account['is_disabled']) {
                 $email_type = $job['job_type'] == "notification" ? "failure_notification" : "failure";
                 send_user_email($user, $email_type, array("name" => $user['name'] ? $user['name'] : $user['email'], "exchange" => get_exchange_name($account_data['exchange']), "label" => $account_data['label'], "labels" => $account_data['labels'], "failures" => number_format($account['failures']), "message" => $runtime_exception->getMessage(), "length" => recent_format(strtotime($account['first_failure']), "", ""), "title" => isset($account['title']) && $account['title'] ? "\"" . $account['title'] . "\"" : "untitled", "url" => absolute_url(url_for("wizard_accounts"))));
                 $logger->info("Sent failure e-mail to " . htmlspecialchars($user['email']) . ".");
             }
         }
     }
 }
开发者ID:phpsource,项目名称:openclerk,代码行数:73,代码来源:GenericOpenclerkJob.php

示例7: sendNotifications

 /**
  * (non-PHPdoc)
  * @see Azine\EmailBundle\Services.NotifierServiceInterface::sendNotifications()
  */
 public function sendNotifications(array &$failedAddresses)
 {
     // get all recipientIds with pending notifications in the database, that are due to be sent
     $recipientIds = $this->getNotificationRecipientIds();
     // get vars that are the same for all recipients of this notification-mail-batch
     $params = $this->getVarsForNotificationsEmail();
     $notificationsTemplate = $this->configParameter[AzineEmailExtension::TEMPLATES . "_" . AzineEmailExtension::NOTIFICATIONS_TEMPLATE];
     foreach ($recipientIds as $recipientId) {
         // send the mail for this recipient
         $failedAddress = $this->sendNotificationsFor($recipientId, $notificationsTemplate, $params);
         if ($failedAddress != null) {
             $failedAddresses[] = $failedAddress;
         }
     }
     // log mail-errors as warnings
     if (sizeof($failedAddresses) > 0) {
         $this->logger->warn("Failed to send message to :\n" . print_r($failedAddresses, true));
     }
     return sizeof($recipientIds) - sizeof($failedAddresses);
 }
开发者ID:xdelacour,项目名称:email-bundle,代码行数:24,代码来源:AzineNotifierService.php

示例8: warn

 /**
  * Adds a log record at the WARNING level.
  *
  * @param string $message The log message
  * @param array $context The log context
  * @return Boolean Whether the record has been processed
  */
 public function warn($message, array $context = array())
 {
     return $this->_logger->warn($message, $context);
 }
开发者ID:360i,项目名称:sonno,代码行数:11,代码来源:MonologAdapter.php

示例9: warn

 /**
  * Adds a log record at the WARNING level.
  * 
  * This method allows for compatibility with common interfaces.
  *
  * @param string $message The log message
  * @param array $context The log context
  * @return Boolean Whether the record has been processed
  * @static 
  */
 public static function warn($message, $context = array())
 {
     return \Monolog\Logger::warn($message, $context);
 }
开发者ID:samcrosoft,项目名称:MicroTranslate,代码行数:14,代码来源:lumen_ide_helper.php

示例10: warn

 /**
  * @param string $message
  * @param array $context
  * @return bool
  */
 public function warn($message, array $context = array())
 {
     return parent::warn($message, $context);
 }
开发者ID:akentner,项目名称:incoming-ftp,代码行数:9,代码来源:LoggerProxy.php

示例11: setLogger

 /**
  * @param \Closure|Logger $logger
  * @return void
  */
 public function setLogger($logger)
 {
     if ($logger instanceof Logger) {
         $this->logger = function ($message, $level) use($logger) {
             switch ($level) {
                 case 'info':
                     $logger->info($message);
                     return;
                 case 'warn':
                 default:
                     $logger->warn($message);
                     return;
             }
         };
     } else {
         $this->logger = $logger;
     }
 }
开发者ID:rotanov,项目名称:fefu-social-network,代码行数:22,代码来源:ServerManager.php

示例12: warning

 /**
  * Exceptional occurrences that are not errors.
  *
  * Example: Use of deprecated APIs, poor use of an API, undesirable things
  * that are not necessarily wrong.
  *
  * @param string $message
  * @param array  $context
  *
  * @return void
  */
 public function warning($message, array $context = array())
 {
     $this->monolog->warn($message, $context);
 }
开发者ID:liip,项目名称:dataaggregator,代码行数:15,代码来源:MonologAdaptor.php

示例13: warn

 /**
  * {@inheritDoc}
  */
 public function warn($msg)
 {
     $this->logger->warn($msg);
 }
开发者ID:smilesrg,项目名称:NsqBundle,代码行数:7,代码来源:MonologAdapter.php


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