本文整理汇总了PHP中Psr\Log\LoggerInterface::info方法的典型用法代码示例。如果您正苦于以下问题:PHP LoggerInterface::info方法的具体用法?PHP LoggerInterface::info怎么用?PHP LoggerInterface::info使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Psr\Log\LoggerInterface
的用法示例。
在下文中一共展示了LoggerInterface::info方法的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;
}
示例2: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
$this->getEntity()->delete();
$this->logger->info('Payment status %label (@id) has been deleted.', ['@id' => $this->getEntity()->id(), '%label' => $this->getEntity()->label()]);
drupal_set_message($this->t('%label has been deleted.', array('%label' => $this->getEntity()->label())));
$form_state->setRedirectUrl($this->getEntity()->urlInfo('collection'));
}
示例3: requestPage
/**
* Request the page from IMDb
* @param $url
* @return string Page html. Empty string on failure
* @throws Exception\Http
*/
protected function requestPage($url)
{
$this->logger->info("[Page] Requesting [{$url}]");
$req = $this->buildRequest($url);
if (!$req->sendRequest()) {
$this->logger->error("[Page] Failed to connect to server when requesting url [{$url}]");
if ($this->config->throwHttpExceptions) {
throw new Exception\Http("Failed to connect to server when requesting url [{$url}]");
} else {
return '';
}
}
if (200 == $req->getStatus()) {
return $req->getResponseBody();
} elseif ($redirectUrl = $req->getRedirect()) {
$this->logger->debug("[Page] Following redirect from [{$url}] to [{$redirectUrl}]");
return $this->requestPage($redirectUrl);
} else {
$this->logger->error("[Page] Failed to retrieve url [{url}]. Response headers:{headers}", array('url' => $url, 'headers' => $req->getLastResponseHeaders()));
if ($this->config->throwHttpExceptions) {
$exception = new Exception\Http("Failed to retrieve url [{$url}]. Status code [{$req->getStatus()}]");
$exception->HTTPStatusCode = $req->getStatus();
throw new $exception();
} else {
return '';
}
}
}
示例4: processGroup
/**
* Process a single group.
*
* Without queuedjobs, it's necessary to shell this out to a background task as this is
* very memory intensive.
*
* The sub-process will then invoke $processor->runGroup() in {@see Solr_Reindex::doReindex}
*
* @param LoggerInterface $logger
* @param SolrIndex $indexInstance Index instance
* @param array $state Variant state
* @param string $class Class to index
* @param int $groups Total groups
* @param int $group Index of group to process
* @param string $taskName Name of task script to run
*/
protected function processGroup(LoggerInterface $logger, SolrIndex $indexInstance, $state, $class, $groups, $group, $taskName)
{
// Build state
$statevar = json_encode($state);
if (strpos(PHP_OS, "WIN") !== false) {
$statevar = '"' . str_replace('"', '\\"', $statevar) . '"';
} else {
$statevar = "'" . $statevar . "'";
}
// Build script
$indexName = $indexInstance->getIndexName();
$scriptPath = sprintf("%s%sframework%scli-script.php", BASE_PATH, DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR);
$scriptTask = "php {$scriptPath} dev/tasks/{$taskName}";
$cmd = "{$scriptTask} index={$indexName} class={$class} group={$group} groups={$groups} variantstate={$statevar}";
$cmd .= " verbose=1 2>&1";
$logger->info("Running '{$cmd}'");
// Execute script via shell
$res = $logger ? passthru($cmd) : `{$cmd}`;
if ($logger) {
$logger->info(preg_replace('/\\r\\n|\\n/', '$0 ', $res));
}
// If we're in dev mode, commit more often for fun and profit
if (Director::isDev()) {
Solr::service($indexName)->commit();
}
// This will slow down things a tiny bit, but it is done so that we don't timeout to the database during a reindex
DB::query('SELECT 1');
}
示例5: handleWebHookAction
/**
* @param Request $request
*
* @Rest\View(statusCode=204)
* @Rest\Post("/webhook", defaults={"_format": "json"})
*
* @throws ResourceConflictException
* @throws \Exception
* @return null
*/
public function handleWebHookAction(Request $request)
{
$this->logger->info($request->getContent());
try {
$event = null;
$store = $this->storeService->getStoreByRequest($request);
$eventId = $this->shopifyEventRetriever->verifyWebhookRequest($request, $store);
$event = $this->shopifyEventRetriever->retrieve($eventId);
if ($event) {
throw new EventAlreadyProcessed(sprintf('Event Id %s has already been processed', $eventId));
}
//Save the event so we don't process this again
$event = Event::createFromRequest($request, $eventId);
$this->eventRepository->save($event);
$cmd = $this->commandFactory->create($event, $store);
$handler = $this->handlerFactory->create($event);
$handler->execute($cmd);
$event->updateStatus(Event::STATUS_PROCESSED);
$this->logger->alert(sprintf('Completed Processing event id %s', $eventId));
} catch (\Exception $e) {
if ($event instanceof Event) {
$event->updateStatus(Event::STATUS_FAILED);
}
$this->logger->alert($e->getMessage());
} finally {
if ($event instanceof Event) {
$this->eventRepository->update($event);
}
return new Response('', 201);
}
}
示例6: execute
/**
* Execute the next task on the queue
*
* @param string $queue
* @param int $timeout
* @throws \Exception
* @throws \mcfedr\Queue\JobManagerBundle\Exception\UnrecoverableException
* @throws \mcfedr\Queue\JobManagerBundle\Exception\ExecuteException
*/
public function execute($queue = null, $timeout = null)
{
$job = $this->manager->get($queue, $timeout);
if (!$job) {
return;
}
$task = json_decode($job->getData(), true);
$this->logger->info('Got task', ['task' => $task['name'], 'options' => $task['options']]);
try {
/** @var Worker $worker */
$worker = $this->container->get($task['name']);
foreach ($this->preListeners as $listener) {
$listener->preTask($worker, $task['options']);
}
$worker->execute($task['options']);
foreach ($this->postListeners as $listener) {
$listener->postTask($worker, $task['options']);
}
$this->manager->delete($job);
} catch (ServiceNotFoundException $e) {
$this->manager->delete($job);
$throw = new UnrecoverableException("Service for job not found", 0, $e);
$throw->setJob($job);
throw $throw;
} catch (UnrecoverableException $e) {
$this->manager->delete($job);
$e->setJob($job);
throw $e;
} catch (\Exception $e) {
throw new ExecuteException($job, $e);
}
}
示例7: createView
/**
* Create an express view from the given XML view, will utilize the cache directory
* to dump and load a template compiled into plain PHP code.
*
* @param ExpressViewRenderer $renderer
* @param string $resource The resource to be compiled into a view.
* @return string The fully-qualified name of the compiled view.
*
* @throws \RuntimeException When the given resource could not be found.
*/
public function createView(ExpressViewRenderer $renderer, $resource)
{
$resource = (string) $resource;
if (!is_file($resource)) {
throw new \RuntimeException(sprintf('Express view not found: "%s"', $resource));
}
$key = $this->createKey($resource);
$typeName = $this->createTypeName($resource);
if (class_exists($typeName, false)) {
return $typeName;
}
$file = $this->cachePath . '/' . $key . '.php';
if (!is_file($file) || filemtime($file) < filemtime($resource)) {
$time = microtime(true);
try {
$code = $this->parseView($renderer, file_get_contents($resource), $resource)->generateCode($key);
} catch (\Exception $e) {
throw new \RuntimeException(sprintf('Unable to parse express view "%s"', $resource), 0, $e);
}
Filesystem::writeFile($file, $code);
$diff = sprintf('%.2f', microtime(true) - $time);
if ($this->logger) {
$this->logger->info('Compiled express view {view}, time spent {time} seconds', ['view' => $resource, 'time' => $diff]);
}
}
require_once $file;
if (!class_exists($typeName, false)) {
throw new \RuntimeException(sprintf('Unable to load compiled express view "%s"', $resource));
}
return $typeName;
}
示例8: _getDependedCalcForExistingPeriod
/**
* Create new depended period and calculation or return existing data.
*
* This function is created for CRAP reducing and is used from this class only.
*
* @param \Praxigento\BonusBase\Service\Period\Response\GetForDependentCalc $result
* @param string $baseCalcTypeCode
* @param string $baseDsBegin
* @param string $baseDsEnd
* @param string $dependentCalcTypeCode
* @param int $dependentCalcTypeId
* @param string $dependentDsBegin
* @param string $dependentDsEnd
*/
public function _getDependedCalcForExistingPeriod(\Praxigento\BonusBase\Service\Period\Response\GetForDependentCalc $result, $baseCalcTypeCode, $baseDsBegin, $baseDsEnd, $dependentCalcTypeCode, $dependentCalcTypeId, $dependentDsBegin, $dependentDsEnd)
{
if ($dependentDsBegin == $baseDsBegin && $dependentDsEnd == $baseDsEnd) {
/* dependent period has the same begin/end as related base period, get calc data */
$this->_logger->info("There is base '{$baseCalcTypeCode}' period for dependent '{$dependentCalcTypeCode}' period ({$dependentDsBegin}-{$dependentDsEnd}).");
$this->_analyzeDependedCalc($result, $dependentCalcTypeCode, $dependentCalcTypeId, $dependentDsBegin, $dependentDsEnd);
} else {
/* dependent period has different begin/end than related base period */
$this->_logger->warning("There is no period for '{$dependentCalcTypeCode}' calculation based on '{$baseCalcTypeCode}' ({$baseDsBegin}-{$baseDsEnd}). New period and related calculation will be created.");
/* create new depended period & calc */
$period = new EPeriod();
$period->setCalcTypeId($dependentCalcTypeId);
$period->setDstampBegin($baseDsBegin);
$period->setDstampEnd($baseDsEnd);
$periodId = $this->_repoPeriod->create($period);
$period->setId($periodId);
/* create related calculation */
$calc = new ECalculation();
$calc->setPeriodId($periodId);
$dateStarted = $this->_toolDate->getUtcNowForDb();
$calc->setDateStarted($dateStarted);
$calc->setState(Cfg::CALC_STATE_STARTED);
$calcId = $this->_repoCalc->create($calc);
$calc->setId($calcId);
/* place new objects into response */
$result->setDependentPeriodData($period);
$result->setDependentCalcData($calc);
}
}
示例9: update
/**
* updates Activity Document Link
* @param array $documentLink
* @param ActivityDocumentLink $activityDocumentLink
* @return bool
*/
public function update(array $documentLink, ActivityDocumentLink $activityDocumentLink)
{
try {
$this->database->beginTransaction();
$documentLinkExists = $activityDocumentLink->exists;
$activityId = $activityDocumentLink->activity_id;
$documentManager = app(DocumentManager::class);
if ($documentLinkExists) {
$url = $activityDocumentLink->document_link['url'];
$document = $documentManager->getDocument(session('org_id'), $url);
$activities = (array) $document->activities;
unset($activities[$activityId]);
$document->activities = $activities;
$documentManager->update($document);
}
$url = $documentLink[0]['url'];
$document = $documentManager->getDocument(session('org_id'), $url);
$activities = (array) $document->activities;
$identifier = $activityDocumentLink->activity->identifier['activity_identifier'];
$activities[$activityId] = $identifier;
$document->activities = $activities;
$documentManager->update($document);
$this->DocumentLinkRepo->update($documentLink, $activityDocumentLink);
$this->database->commit();
$this->logger->info(sprintf('Activity Document Link %s!', $documentLinkExists ? 'updated' : 'saved'), ['for' => $documentLink]);
$this->dbLogger->activity(sprintf("activity.document_link_%s", $documentLinkExists ? 'updated' : 'saved'), ['activity_id' => $activityDocumentLink->activity_id, 'document_link_id' => $activityDocumentLink->id, 'organization' => $this->auth->user()->organization->name, 'organization_id' => $this->auth->user()->organization->id]);
return true;
} catch (\Exception $exception) {
$this->database->rollback();
$this->logger->error($exception, ['documentLink' => $documentLink]);
}
return false;
}
示例10: r4_add_record
protected function r4_add_record(CreatedDomain $domain, Record $record)
{
if ($this->logger) {
$this->logger->info("Adding " . $record->name);
}
return $domain->add_record($record, $this->api);
}
示例11: log
/**
* @param $message
* @param $context
*/
private function log($message, $context = [])
{
if ($this->logger instanceof LoggerInterface) {
$context['class'] = self::class;
$this->logger->info($message, $context);
}
}
示例12: 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);
}
}
示例13: info
public static function info($msg, $context = array())
{
if (!self::$_impl) {
return;
}
self::$_impl->info($msg, $context);
}
示例14: runCrons
public function runCrons()
{
$entityManager = $this->managerRegistry->getManagerForClass('DspSoftsCronManagerBundle:CronTask');
$cronTaskRepo = $entityManager->getRepository('DspSoftsCronManagerBundle:CronTask');
$cronTasks = $cronTaskRepo->findCronsToLaunch();
foreach ($cronTasks as $cronTask) {
$run = true;
if (!$cronTask->getRelaunch()) {
$run = $this->planificationChecker->isExecutionDue($cronTask->getPlanification());
}
if ($run) {
if ($this->logger !== null) {
$this->logger->info(sprintf('Running Cron Task <info>%s</info>', $cronTask->getName()));
}
$cli = 'exec ' . $this->kernelRootDir . DIRECTORY_SEPARATOR . 'console dsp:cron:runjob -c ' . $cronTask->getId() . ' &';
if ($this->logger !== null) {
$this->logger->info(sprintf('Command line : <info>%s</info>', $cli));
}
$process = new Process($cli);
$process->setTimeout(0);
$process->start();
} else {
if ($this->logger !== null) {
$this->logger->info(sprintf('Skipping Cron Task <info>%s</info>', $cronTask->getName()));
}
}
}
}
示例15: inlineQuery
public function inlineQuery(Update $update) : unreal4uBot
{
$this->logger->info(sprintf('Received inline query. User id %d (username: %s). Query: "%s", inline query id: %s', $update->inline_query->from->id, $update->inline_query->from->username, $update->inline_query->query, $update->inline_query->id));
$query = $update->inline_query->query;
if (empty($query)) {
$query = 'What is lmgtfy?';
}
// Number of results
$i = 1;
$inlineQueryResultArticle = new Article();
$inlineQueryResultArticle->url = 'http://lmgtfy.com/?q=' . urlencode($query);
$inlineQueryResultArticle->title = $inlineQueryResultArticle->url;
//'Forward this message to anyone you would like (Title)';
$inlineQueryResultArticle->hide_url = true;
$inputMessageContentText = new Text();
$inputMessageContentText->message_text = $inlineQueryResultArticle->url;
$inputMessageContentText->disable_web_page_preview = true;
$inlineQueryResultArticle->input_message_content = $inputMessageContentText;
// @TODO find a way to compress this all into an identifiable 64bit ascii string, maybe with pack()?
$inlineQueryResultArticle->id = md5(json_encode(['uid' => $update->inline_query->from->id, 'iqid' => $update->inline_query->id, 'rid' => $i]));
$answerInlineQuery = new AnswerInlineQuery();
$answerInlineQuery->inline_query_id = $update->inline_query->id;
$answerInlineQuery->addResult($inlineQueryResultArticle);
$tgLog = new TgLog($this->token, $this->logger);
//$tgLog->logger = $this->logger;
$tgLog->performApiRequest($answerInlineQuery);
$this->logger->info(sprintf('Sent API response to Telegram, all done'));
return $this;
}