public function run() { $endTime = time() + $this->lifetime; $this->logger->info(sprintf('Started listening with a lifetime of %d seconds.', $this->lifetime)); while (time() < $endTime) { try { /** @var \Pheanstalk\Job $job */ $job = $this->pheanstalk->reserve(1); } catch (Exception $exception) { } if ($job) { $this->logger->info(sprintf('Reserved job #%d: %s', $job->getId(), $job->getData())); try { $data = json_decode($job->getData(), true); /** @var WorkerInterface $worker */ $worker = $this->workerManager->get($data['worker'], $data['params']); $worker->run(new Context($this, $this->logger, $data['params'])); $this->logger->info(sprintf('Finished job #%d', $job->getId())); $this->pheanstalk->delete($job); } catch (Exception $exception) { $this->logger->emerg('Failed to execute job #' . $job->getId(), ['exception' => $exception]); $this->pheanstalk->bury($job); } } usleep($this->interval); } }
/** * @param string $message */ public function logInfo($message) { if (!is_null($this->getLogger())) { $this->logger->info($message); } if (!is_null($this->getConsoleOutput())) { $this->consoleOutput->writeln("<comment>" . $message . "</comment>"); } }
/** * @param string $messageBody * @param array $attributes * @param array $options * @return MessageSentInterface */ public function sendMessage($messageBody, array $attributes = [], array $options = []) { $message = <<<EOT Send message called with : - Message : %s - Attributes : %s - Options : %s EOT; $this->logger->info(sprintf($message, $messageBody, json_encode($attributes), json_encode($options))); return (new Message())->setId('Fake received message')->setBody($messageBody)->setAttributes($attributes); }
/** * Logout * * Redirects To: Route 'home' */ public function logoutAction() { $auth = $this->auth; $this->logger->info('User ' . ($auth->getUser()->login == '' ? $auth->getUser()->info->displayName : $auth->getUser()->login) . ' logged out'); $auth->clearIdentity(); unset($_SESSION['HA::STORE']); $this->notification()->success('You are now logged out'); return $this->redirect()->toRoute('lang', array('lang' => $this->params('lang'))); }
/** * Logs a message using the logger. * * @param string $message */ public function info($message) { if (isset($this->logger)) { $this->logger->info($message); } }