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


PHP Logger::addInfo方法代码示例

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


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

示例1: log

 public function log($message, $priority = self::INFO)
 {
     if ($message instanceof \Exception) {
         $message = $message->getMessage();
         $context = [];
     } elseif (is_string($message)) {
         $context = [];
     } else {
         $context = $message;
         unset($context[0]);
         unset($context[1]);
         if (isset($message[1])) {
             $message = preg_replace('#\\s*\\r?\\n\\s*#', ' ', trim($message[1]));
         }
     }
     switch ($priority) {
         case self::DEBUG:
             return $this->monolog->addDebug($message, $context);
         case self::CRITICAL:
             return $this->monolog->addCritical($message, $context);
         case self::ERROR:
             return $this->monolog->addError($message, $context);
         case self::EXCEPTION:
             return $this->monolog->addEmergency($message, $context);
         case self::WARNING:
             return $this->monolog->addWarning($message, $context);
         case 'access':
             return $this->monolog->addNotice($message, $context);
         case 'emergency':
             return $this->monolog->addEmergency($message, $context);
         default:
             return $this->monolog->addInfo($message, $context);
     }
 }
开发者ID:bazo,项目名称:nette-monolog-extension,代码行数:34,代码来源:MonologAdapter.php

示例2: updateCommunityDateStat

 /**
  * @param Pantheon $community
  * @param OutputInterface    $output
  */
 private function updateCommunityDateStat(Pantheon $community, OutputInterface $output)
 {
     $this->logger->addInfo(sprintf('Update community "%s" with id %s', $community->getName(), $community->getId()));
     $today = new \DateTime('-4 hour');
     /** @var PantheonDateStat[] $communityDateStat */
     $communityDateStat = $community->getDateStat();
     if (count($communityDateStat) && $communityDateStat->first()->getDate()->format('Y:m:d') == $today->format('Y:m:d')) {
         $this->logger->addInfo(sprintf('Community "%s" with id %s already parsed today', $community->getName(), $community->getId()));
         return;
     }
     $aggregator = array('sumPrestige' => 0, 'maxPrestige' => 0, 'pveSumMobKills' => 0, 'pveSumBossKills' => 0, 'pveSumDeaths' => 0, 'pvpSumTime' => 0, 'pvpSumKills' => 0, 'pvpSumDeaths' => 0, 'pvpSumAssists' => 0);
     /** @var Player $member */
     foreach ($community->getMembers() as $member) {
         if (!count($member->getDateStat())) {
             continue;
         }
         /** @var PlayerDateStat $lastPlayerDateStat */
         $lastPlayerDateStat = $member->getDateStat()->first();
         $aggregator['sumPrestige'] += $lastPlayerDateStat->getMaxPrestige();
         $aggregator['maxPrestige'] = $aggregator['maxPrestige'] < $lastPlayerDateStat->getMaxPrestige() ? $lastPlayerDateStat->getMaxPrestige() : $aggregator['maxPrestige'];
         $aggregator['pvpSumTime'] += $lastPlayerDateStat->getPvpTime();
         //            $aggregator['pveSumTime'] += $lastPlayerDateStat->getPveTime();
         foreach ($member->getRoleStat() as $role) {
             $aggregator['pveSumMobKills'] += $role->getPveMobKills();
             $aggregator['pveSumBossKills'] += $role->getPveBossKills();
             $aggregator['pveSumDeaths'] += $role->getPveDeaths();
             $aggregator['pvpSumKills'] += $role->getPvpKills();
             $aggregator['pvpSumDeaths'] += $role->getPvpDeaths();
             $aggregator['pvpSumAssists'] += $role->getPvpAssists();
         }
     }
     $newPantheonDateStat = new PantheonDateStat();
     $newPantheonDateStat->setPantheon($community)->setDate($today)->setSumPrestige($aggregator['sumPrestige'])->setAvgPrestige(count($community->getMembers()) ? round($aggregator['sumPrestige'] / count($community->getMembers())) : 0)->setMembersCount(count($community->getMembers()))->setMaxPrestige($aggregator['maxPrestige'])->setPveSumMobKills($aggregator['pveSumMobKills'])->setPveSumBossKills($aggregator['pveSumBossKills'])->setPveSumDeaths($aggregator['pveSumDeaths'])->setPvpSumTime($aggregator['pvpSumTime'])->setPvpSumKills($aggregator['pvpSumKills'])->setPvpSumDeaths($aggregator['pvpSumDeaths'])->setPvpSumAssists($aggregator['pvpSumAssists']);
     $this->em->persist($newPantheonDateStat);
 }
开发者ID:Erliz,项目名称:skyforge-bundle,代码行数:39,代码来源:UpdatePantheonDateStatCommand.php

示例3: terminate

 public function terminate($request, $response)
 {
     $log = new Logger('HTTP');
     $handler = new RotatingFileHandler(config('laravelmiddlewarelogger.options.file'), Logger::INFO);
     $handler->setFormatter(new LineFormatter("[%datetime%] %channel%.%level_name%: %message% %context%\n\n"));
     $log->pushHandler($handler);
     if (config('laravelmiddlewarelogger.options.enabled')) {
         $inputs = $request->input();
         if (!empty($inputs)) {
             $inputSafe = config('laravelmiddlewarelogger.options.input_safe');
             foreach ($inputSafe as $safe) {
                 if (!empty($inputs[$safe])) {
                     $inputs[$safe] = '[*** SENSOR ***]';
                 }
             }
         }
         $request_array = ['method' => $request->method(), 'full-url' => $request->fullUrl(), 'client-ip' => $request->ip(), 'user-agent' => $request->header('user-agent'), 'query-string' => $request->query(), 'inputs' => $inputs];
         $response_array = [];
         if (config('laravelmiddlewarelogger.options.log_response')) {
             $response_array = ['status' => $response->status(), 'content' => ''];
             json_decode($response->content());
             if (json_last_error() == JSON_ERROR_NONE) {
                 $response_array['content'] = $response->content();
             }
         }
         $log->addInfo('REQUEST', $request_array);
         $log->addInfo('RESPONSE', $response_array);
     }
 }
开发者ID:quintet-solutions,项目名称:laravel-middleware-logger,代码行数:29,代码来源:LogAfterRequest.php

示例4: findCommunities

 /**
  * @param OutputInterface $output
  */
 private function findCommunities(OutputInterface $output)
 {
     $this->logger->addInfo('Finding new communities');
     $communities = array();
     try {
         for ($page = 1; $page <= 20; $page++) {
             $responseMessage = $this->parseService->getPage($this->makeCommunitiesMoreUrl(), true, $this->makeCommunitiesUrl(), array('t:zone' => 'bunchZone', 'bunchIndex' => $page));
             $response = json_decode($responseMessage);
             if (!$response) {
                 $this->logger->addInfo(sprintf('Empty page %s', $page));
                 break;
             }
             $pageCommunities = $this->parseService->getCommunities($response->content);
             $this->logger->addInfo(sprintf('Page %s parsed successful, get %s communities', $page, count($pageCommunities)));
             $communities = $communities + $pageCommunities;
             usleep(rand(500, 1500) * 1000);
         }
     } catch (RuntimeException $e) {
         $this->logger->addInfo('Exception: ' . $e->getMessage() . ' ' . $e->getCode());
     }
     foreach ($communities as $parsedCommunity) {
         $community = $this->pantheonRepository->find($parsedCommunity->id);
         if ($community) {
             continue;
         }
         $community = new Pantheon();
         $community->setId($parsedCommunity->id)->setImg($parsedCommunity->pic)->setName($parsedCommunity->name)->setIsActive(0)->setUpdatedAt(new DateTime());
         $this->em->persist($community);
     }
     $this->em->flush();
 }
开发者ID:Erliz,项目名称:skyforge-bundle,代码行数:34,代码来源:FindPantheonInfoCommand.php

示例5: getLogger

 public function getLogger($message)
 {
     if ($this->logger == null) {
         $this->setLogger();
     }
     $this->logger->addInfo($message);
 }
开发者ID:kirschbaum,项目名称:drupal-behat-remote-api-driver,代码行数:7,代码来源:LoggingListener.php

示例6: sendPush

 public static function sendPush($deviceToken, $message, $data = null, $type = null)
 {
     $log = new \Monolog\Logger('notifications');
     $log->pushHandler(new \Monolog\Handler\StreamHandler(Env::$config->logPath . 'notifications.log', Logger::DEBUG));
     $log->addInfo('Entering to send a push');
     if (strlen($deviceToken) == 64) {
         $log->addInfo('Sending notification to ios device', ["deviceToken" => $deviceToken]);
         $ctx = stream_context_create();
         //dev pem /home7/quesoazu/www/doyride/push/dev_key.pem
         stream_context_set_option($ctx, 'ssl', 'local_cert', Env::$config->pem);
         stream_context_set_option($ctx, 'ssl', 'passphrase', Env::$config->passphrase);
         // Open a connection to the APNS server
         // DEV APNS gateway.sandbox.push.apple.com:2195
         $fp = stream_socket_client(Env::$config->apns, $err, $errstr, 60, STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT, $ctx);
         if (!$fp) {
             exit("Failed to connect: {$err} {$errstr}" . PHP_EOL);
         }
         //echo 'Connected to APNS' . PHP_EOL;
         // Create the payload body
         $body['aps'] = array('alert' => $message, 'sound' => 'default', 'content-available' => 1);
         $body['d'] = $data;
         $body['t'] = $type;
         // Encode the payload as JSON
         $payload = json_encode($body);
         // Build the binary notification
         $msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n', strlen($payload)) . $payload;
         // Send it to the server
         $result = fwrite($fp, $msg, strlen($msg));
         $log->addDebug($result);
         // Close the connection to the server
         fclose($fp);
     } else {
         $log->addInfo('Sending notification to android device', ["deviceToken" => $deviceToken]);
         //AIzaSyBpweimzrQ-5pjUO1absB4cTrDVRHIxmMg
         $api_key = Env::$config->apikey;
         //$registrationIDs = array("APA91bHOZnfPwVys28cus-w9s18zZw4lXb-CU1Os8OiA2MpLpvGc4b9sxipnAVZNiDHe3iWv4T-_5B7UHJ_ce2ybu_w_Z4Y_kXWsIJqE4bjyF0tcrZrofszmE42xJ_sg15Tw2yG2IxVXcFu37LyP7ZHx9DqRqqRByPSLUwkrUqzqavQSWt1A3l4");
         $registrationIDs = array($deviceToken);
         $message = $message;
         $url = 'https://android.googleapis.com/gcm/send';
         /*$body['registration_ids'] = $deviceToken;
         		$body['aps'] = array(		                
         	                'alert'             => $message,
         	                'sound'				=> 'default'
         	                );
         		$body['d'] = $data;
         		$body['t'] = $type;*/
         $fields = array('registration_ids' => $registrationIDs, 'data' => array("message" => $message, "d" => $data, "t" => $type));
         $headers = array('Authorization: key=' . $api_key, 'Content-Type: application/json');
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $url);
         curl_setopt($ch, CURLOPT_POST, true);
         curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($fields));
         $result = curl_exec($ch);
         $log->addDebug($result);
         curl_close($ch);
     }
 }
开发者ID:renomx,项目名称:apistarter,代码行数:59,代码来源:Notification.php

示例7: onClose

 /**
  * {@inheritdoc}
  */
 public function onClose(ConnectionInterface $conn)
 {
     $this->_i--;
     if (null !== $this->_in) {
         $this->_in->addInfo('onClose', array('#open' => $this->_i, 'id' => $conn->resourceId));
     }
     $this->_component->onClose($conn);
 }
开发者ID:ksonglover,项目名称:socketo.me,代码行数:11,代码来源:MessageLogger.php

示例8: onResponse

 /**
  * When a message appears, it checks the correlation_id property. If it
  * matches the value from the request it returns the response to the
  * application.
  *
  * @param AMQPMessage $rep
  */
 public function onResponse(AMQPMessage $rep)
 {
     $this->log->addInfo('Received response');
     if ($rep->get('correlation_id') == $this->corr_id) {
         $this->log->addInfo('Correlation id matches, setting response: ' . $rep->body);
         $this->response = $rep->body;
     }
 }
开发者ID:aslijiasheng,项目名称:SPRabbitMQ,代码行数:15,代码来源:RpcSender.php

示例9: onSecurityInteractiveLogin

 /**
  * Handle login event.
  *
  * @param InteractiveLoginEvent $event
  */
 public function onSecurityInteractiveLogin(InteractiveLoginEvent $event)
 {
     /* @var BaseUser $user */
     $user = $event->getAuthenticationToken()->getUser();
     if ($user instanceof UserInterface) {
         $this->logger->addInfo($user . ' successfully logged in to the cms');
         $this->versionChecker->periodicallyCheck();
     }
 }
开发者ID:hyrmedia,项目名称:KunstmaanBundlesCMS,代码行数:14,代码来源:LoginListener.php

示例10: execute

 /**
  * Sends an invoice generation task to the workers
  * 
  * @param int $invoiceNum
  */
 public function execute($invoiceNum)
 {
     $this->log->addInfo('Received invoice for processing: ' . $invoiceNum);
     $connection = new AMQPConnection('localhost', 5672, 'guest', 'guest');
     $channel = $connection->channel();
     $channel->queue_declare('invoice_queue', false, true, false, false);
     $msg = new AMQPMessage($invoiceNum, array('delivery_mode' => 2));
     $channel->basic_publish($msg, '', 'invoice_queue');
     $this->log->addInfo('Published task to worker');
     $channel->close();
     $connection->close();
 }
开发者ID:aslijiasheng,项目名称:SPRabbitMQ,代码行数:17,代码来源:WorkerSender.php

示例11: run

 public function run()
 {
     $configFile = tempnam(sys_get_temp_dir(), 'satis-admin');
     file_put_contents($configFile, $this->manager->getJson());
     $process = ProcessBuilder::create(['php', $this->binDir . '/satis', 'build', $configFile, $this->outputDir])->getProcess();
     $this->logger->addInfo('Building config...', ['command-line' => $process->getCommandLine()]);
     if (0 === $process->run()) {
         $this->logger->addInfo('Config built.');
     } else {
         $this->logger->addError('Config not build', ['stdout' => $process->getOutput(), 'stderr' => $process->getErrorOutput()]);
     }
 }
开发者ID:blackstylle,项目名称:satis-admin,代码行数:12,代码来源:SatisRunner.php

示例12: run

 public function run()
 {
     $configFile = tempnam($this->cacheDir . '/satis', 'satis-admin');
     file_put_contents($configFile, $this->manager->getJson());
     $process = ProcessBuilder::create(['php', $this->binDir . '/satis', 'build', $configFile, $this->outputDir])->setTimeout(null)->addEnvironmentVariables(['HOME' => $this->cacheDir])->getProcess();
     $this->logger->addInfo('Building config...', ['command-line' => $process->getCommandLine()]);
     if (0 === $process->run()) {
         unlink($configFile);
         $this->logger->addInfo('Config built.');
     } else {
         $this->logger->addError('Config not build', ['stdout' => $process->getOutput(), 'stderr' => $process->getErrorOutput()]);
     }
 }
开发者ID:yohang,项目名称:satis-admin,代码行数:13,代码来源:SatisRunner.php

示例13: execute

 /**
  * Sends a message to the pizzaTime queue.
  * 
  * @param string $message
  */
 public function execute($message)
 {
     $this->log->addInfo('Received message to send: ' . $message);
     $connection = new AMQPConnection('localhost', 5672, 'guest', 'guest');
     /** @var $channel AMQPChannel */
     $channel = $connection->channel();
     $channel->queue_declare('pizzaTime', false, false, false, false);
     $msg = new AMQPMessage($message);
     $channel->basic_publish($msg, '', 'pizzaTime');
     $this->log->addInfo('Message sent');
     $channel->close();
     $connection->close();
 }
开发者ID:aslijiasheng,项目名称:SPRabbitMQ,代码行数:18,代码来源:SimpleSender.php

示例14: onKernelException

 /**
  * Captura los eventos generados por las excepciones y
  * escribe en el fichero logs/excepciones.log información de cada una de ellas.
  * Responde al RF (58)(Configurar y registrar  datos  de las excepciones)
  *
  * @param GetResponseForExceptionEvent $event
  */
 public function onKernelException(GetResponseForExceptionEvent $event)
 {
     $exception = $event->getException();
     $logger = new Logger('excepciones');
     $stream = new StreamHandler($this->rootLogsDir . $this->fileName, Logger::DEBUG);
     $output = "[%datetime%]: %message% %context% \n";
     $stream->setFormatter(new ExcepcionesFormatter($output));
     $logger->pushHandler($stream);
     if ($exception instanceof LocalException) {
         $logger->addInfo("LocalException", array("codigo" => $exception->getCodigo(), "mensaje" => $exception->getMensaje(), "descripcion" => $exception->getDescripcion(), "clase" => $exception->getClase(), "linea" => $exception->getLinea(), "metodo" => $exception->getMetodo(), "traza" => $exception->getTraceAsString()));
     } else {
         $trazas = $exception->getTrace();
         $logger->addInfo(get_class($exception), array("codigo" => $exception->getCode(), "mensaje" => $exception->getMessage(), "clase" => $exception->getFile(), "linea" => $exception->getLine(), "metodo" => $trazas[0]['function'], "traza" => $exception->getTraceAsString()));
     }
 }
开发者ID:bosonsymfony,项目名称:excepciones-bundle,代码行数:22,代码来源:ExceptionListener.php

示例15: actionUpdate

 public function actionUpdate($id, $hash)
 {
     $project = $this->projectFacade->find($id);
     $data = $this->getHttpRequest()->getRawBody();
     $verifyHash = hash_hmac('sha256', $data, $project->getKey());
     $messageData = unserialize($data);
     $this->logger->addInfo('importing ', $messageData);
     if ($hash === $verifyHash) {
         $imported = $this->projectFacade->importTemplate($messageData, $project);
         $this->sendResponse(new \Nette\Application\Responses\JsonResponse(['error' => 'false', 'message' => sprintf('OK. Imported %d messages.', $imported)]));
     } else {
         $this->sendResponse(new \Nette\Application\Responses\JsonResponse(['error' => 'true', 'message' => 'Bad request. Hash does not match.']));
     }
     $this->terminate();
 }
开发者ID:bazo,项目名称:translation-ui,代码行数:15,代码来源:ProjectsPresenter.php


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