本文整理匯總了PHP中Psr\Log\LoggerInterface::alert方法的典型用法代碼示例。如果您正苦於以下問題:PHP LoggerInterface::alert方法的具體用法?PHP LoggerInterface::alert怎麽用?PHP LoggerInterface::alert使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Psr\Log\LoggerInterface
的用法示例。
在下文中一共展示了LoggerInterface::alert方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: alert
/**
* Action must be taken immediately.
*
* Example: Entire website down, database unavailable, etc. This should
* trigger the SMS alerts and wake you up.
*
* @param string $message
* @param array $context
* @return null
*/
public function alert($message, array $context = array())
{
if ($this->logger) {
$context = $this->getLoggerContext($context);
$this->logger->alert($message, $context);
}
}
示例2: onShutdown
/**
* When the process is shutdown we will check for errors.
*/
public function onShutdown()
{
$error = error_get_last();
if (!empty($error) && isset($error['type']) && error_reporting()) {
$this->logger->alert($error['message'], ['error' => new Error($error['message'], $error['line'], $error['file'])]);
}
}
示例3: alert
/**
* Action must be taken immediately.
*
* Example: Entire website down, database unavailable, etc. This should
* trigger the SMS alerts and wake you up.
*
* @param string $message
* @param array $context
* @return bool
*/
public function alert($message, array $context = array())
{
if (self::isSetLogger()) {
return self::$logger->alert($message, $context);
}
return false;
}
示例4: setWorkingDirectory
/**
* @param string $path the working directory for filesystem operations
*
* @throws \InvalidArgumentException
* @throws IOException
*/
public function setWorkingDirectory($path)
{
$directory = preg_replace('#/+#', '/', $path);
// remove multiple slashes
try {
$directory = $this->locator->locate($directory);
if (false === is_string($directory)) {
$directory = strval(reset($directory));
$this->logger->alert(sprintf('Ambiguous filename %s, choosing %s', $path, $directory));
}
} catch (\InvalidArgumentException $exception) {
// continue to check if dir exists even if locator doesn't locate
}
$exists = $this->filesystem->exists($directory);
if (!$exists) {
try {
$this->filesystem->mkdir($directory);
$this->logger->notice("Working directory created at " . $directory);
} catch (IOException $exception) {
$this->logger->error("An error occurred while creating directory at " . $exception->getPath(), $exception->getTrace());
throw $exception;
}
}
$this->directory = $directory;
}
示例5: log
/**
* {@inheritdoc}
*/
public function log($message, $level)
{
$message .= ' ' . $this->request->getRequestUri();
if ($this->logLevel >= $level) {
switch ($level) {
case self::EMERGENCY:
$this->logger->emergency($message);
break;
case self::ALERT:
$this->logger->alert($message);
break;
case self::CRITICAL:
$this->logger->critical($message);
break;
case self::ERROR:
$this->logger->error($message);
break;
case self::WARNING:
$this->logger->warning($message);
break;
case self::NOTICE:
$this->logger->notice($message);
break;
case self::INFO:
$this->logger->info($message);
break;
default:
$this->logger->debug($message);
}
}
}
示例6: send
/**
* @param RequestableInterface $apiRequest
*
* @return bool|\GuzzleHttp\Message\ResponseInterface
*/
public function send(RequestableInterface $apiRequest)
{
$request = $this->guzzleClient->createRequest($apiRequest->getMethod(), $apiRequest->getUrl(), $apiRequest->getOptions());
try {
return $this->guzzleClient->send($request);
} catch (ClientException $e) {
if (null !== $this->logger) {
$this->logger->alert($e->getMessage());
}
return false;
}
}
示例7: signalHandler
/**
* @param int $signal
* @return void
*/
public function signalHandler($signal)
{
switch ($signal) {
case SIGINT:
case SIGTERM:
$this->logger->alert('Worker killed or terminated', array('sessionId', $this->sessionId));
$this->daemonizable->shutdown();
exit(1);
break;
case SIGHUP:
$this->logger->info('Starting daemon', array('session' => $this->sessionId));
break;
}
}
示例8: doLog
/**
* Logs a message.
*
* @param string $message Message
* @param string $priority Message priority
*
* @return void
*/
public function doLog($message, $priority)
{
if (!$this->logger) {
$this->buffer[] = compact('message', 'priority');
return;
}
switch ($priority) {
case sfLogger::EMERG:
$this->logger->emergency($message);
break;
case sfLogger::ALERT:
$this->logger->alert($message);
break;
case sfLogger::CRIT:
$this->logger->critical($message);
break;
case sfLogger::ERR:
$this->logger->error($message);
break;
case sfLogger::WARNING:
$this->logger->warning($message);
break;
case sfLogger::NOTICE:
$this->logger->notice($message);
break;
case sfLogger::INFO:
$this->logger->info($message);
break;
case sfLogger::DEBUG:
$this->logger->debug($message);
break;
}
}
示例9: 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);
}
}
示例10: generateMenu
/**
* @param ItemInterface $menu
* @param AdminMenu[] $tree
* @param int $level
*/
protected function generateMenu(&$menu, &$tree, $level = 0)
{
while (!empty($tree)) {
$item = array_shift($tree);
$type = $item->getType();
$itemLabel = $item->getTitle();
$itemLevel = $item->getLevel();
if ($itemLevel == $level) {
$options = [];
if (AdminMenu::TYPE_FOLDER !== $type) {
$admin = $this->pool->getInstance($item->getServiceId());
if ($admin) {
$options = $admin->generateMenuUrl('list');
$options['extras'] = ['admin' => $admin];
} else {
$this->logger->alert('Admin not found for class', [$item->getServiceId()]);
}
}
$child = $menu->addChild($itemLabel, $options);
} elseif ($itemLevel > $level) {
array_unshift($tree, $item);
$this->generateMenu($child, $tree, $itemLevel);
} else {
array_unshift($tree, $item);
break;
}
}
}
示例11: getHandlers
/**
* @param MessageInterface $message
* @return MessageHandlerInterface[]
* @throws EventBusException
*/
public function getHandlers(MessageInterface $message)
{
$handlers = [];
$eventName = $message->getName();
if (!array_key_exists($eventName, $this->map)) {
return $handlers;
}
foreach ($this->map[$eventName] as $handlerName) {
try {
$handlers[] = $this->locator->get($handlerName);
} catch (\Exception $e) {
$this->logger->alert($e->getMessage(), ['exception' => $e]);
}
}
return $handlers;
}
示例12: addSignals
private function addSignals()
{
\Amp\onSignal(SIGINT, function () {
exit;
});
\Amp\onSignal(SIGTERM, function () {
exit;
});
register_shutdown_function(function () {
$this->logger->alert('Clean exit. Thank you.');
if (\Amp\info()["state"] !== \Amp\Reactor::STOPPED) {
\Amp\stop();
}
});
return true;
}
示例13: alert
/**
* {@inheritdoc}
*/
public function alert($message, array $context = array())
{
if (!$this->logger) {
return;
}
return $this->logger->alert($message, $context);
}
示例14: alert
/**
* Action must be taken immediately.
*
* Example: Entire website down, database unavailable, etc. This should
* trigger the SMS alerts and wake you up.
*
* @param string $message
* @param array $context
* @return null
*/
public function alert($message, array $context = array())
{
if (empty($this->logger)) {
return;
}
$this->logger->alert($this->getDefaultMessage() . $message, $context);
}
示例15: setValue
private function setValue(&$item, $key, $value, $options = [])
{
try {
$this->debug && $this->logger->info("Value adding is started.");
switch ($options['type']) {
case "string":
case "text":
case "integer":
case "collection":
case "bool":
if (isset($options['modifier'])) {
$value = $this->modify($value, $options['modifier'], $item);
}
break;
case "date":
if (isset($options['modifier'])) {
$value = $this->modify($value, $options['modifier'], $item);
} else {
$value = $this->modifyDate($value, $options);
}
break;
case "object":
$value = $this->setObjectValue($item, $key, $value, $options);
break;
}
if (array_key_exists('value', $options)) {
$value = $options['value'];
}
$value ? $this->accessor->setValue($item, $key, $value) : $this->logger->alert("Value is null for {$key}.");
$this->debug && $this->logger->info("Value adding is completed.");
} catch (\Exception $e) {
$this->logger->critical($e->getMessage());
}
}