本文整理匯總了PHP中Psr\Log\LoggerInterface::critical方法的典型用法代碼示例。如果您正苦於以下問題:PHP LoggerInterface::critical方法的具體用法?PHP LoggerInterface::critical怎麽用?PHP LoggerInterface::critical使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Psr\Log\LoggerInterface
的用法示例。
在下文中一共展示了LoggerInterface::critical方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: assign
/**
* {@inheritDoc}
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function assign($cartId, \Magento\Quote\Api\Data\AddressInterface $address)
{
/** @var \Magento\Quote\Model\Quote $quote */
$quote = $this->quoteRepository->getActive($cartId);
if ($quote->isVirtual()) {
throw new NoSuchEntityException(__('Cart contains virtual product(s) only. Shipping address is not applicable.'));
}
$saveInAddressBook = $address->getSaveInAddressBook() ? 1 : 0;
$sameAsBilling = $address->getSameAsBilling() ? 1 : 0;
$customerAddressId = $address->getCustomerAddressId();
$this->addressValidator->validate($address);
$quote->setShippingAddress($address);
$address = $quote->getShippingAddress();
if ($customerAddressId) {
$addressData = $this->addressRepository->getById($customerAddressId);
$address = $quote->getShippingAddress()->importCustomerAddressData($addressData);
} elseif ($quote->getCustomerId()) {
$address->setEmail($quote->getCustomerEmail());
}
$address->setSameAsBilling($sameAsBilling);
$address->setSaveInAddressBook($saveInAddressBook);
$address->setCollectShippingRates(true);
try {
$address->collectTotals()->save();
} catch (\Exception $e) {
$this->logger->critical($e);
throw new InputException(__('Unable to save address. Please, check input data.'));
}
if (!$quote->validateMinimumAmount($quote->getIsMultiShipping())) {
throw new InputException($this->scopeConfig->getValue('sales/minimum_order/error_message', \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $quote->getStoreId()));
}
return $quote->getShippingAddress()->getId();
}
示例2: render
/**
* {@inheritdoc}
*/
public function render(BlockContextInterface $blockContext, Response $response = null)
{
$block = $blockContext->getBlock();
if ($this->logger) {
$this->logger->info(sprintf('[cms::renderBlock] block.id=%d, block.type=%s ', $block->getId(), $block->getType()));
}
try {
$service = $this->blockServiceManager->get($block);
$service->load($block);
$response = $service->execute($blockContext, $this->createResponse($blockContext, $response));
if (!$response instanceof Response) {
$response = null;
throw new \RuntimeException('A block service must return a Response object');
}
$response = $this->addMetaInformation($response, $blockContext, $service);
} catch (\Exception $exception) {
if ($this->logger) {
$this->logger->critical(sprintf('[cms::renderBlock] block.id=%d - error while rendering block - %s', $block->getId(), $exception->getMessage()));
}
// reseting the state object
$this->lastResponse = null;
$response = $this->exceptionStrategyManager->handleException($exception, $blockContext->getBlock(), $response);
}
return $response;
}
示例3: execute
/**
* Start the backup.
*
* @return bool
*/
public function execute()
{
$successful = true;
try {
// Dump all databases
$this->dbm->dump();
// Backup folders if specified
$this->logger->info('[dizda-backup] Copying folders.');
$this->processor->copyFolders();
// Compress everything
$this->logger->info(sprintf('[dizda-backup] Compressing to archive using %s', $this->processor->getName()));
$this->processor->compress();
// Transfer with all clients
$this->cm->upload($this->processor->getArchivePath());
} catch (\Exception $e) {
// Write log
$this->logger->critical('[dizda-backup] Unexpected exception.', array('exception' => $e));
$successful = false;
}
try {
// If we catch an exception or not, we would still like to try cleaning up after us
$this->logger->info('[dizda-backup] Cleaning up after us.');
$this->processor->cleanUp();
} catch (IOException $e) {
$this->logger->error('[dizda-backup] Cleaning up failed.');
return false;
}
return $successful;
}
示例4: __invoke
/**
* @param \Psr\Http\Message\ServerRequestInterface $request
* @param \Psr\Http\Message\ResponseInterface $response
* @param \Throwable $error
*
* @return \Psr\Http\Message\ResponseInterface
*/
public function __invoke(Request $request, Response $response, Throwable $error) : Response
{
if (!$this->shouldntReport($error)) {
$this->logger->critical($error->getMessage());
}
return call_user_func($this->handler, $request, $response, $error);
}
示例5: onError
/**
* Handle errors.
*
* @param int $code Contains the level of the error raised, as an integer.
* @param string $message The error message.
* @param string $file The filename that the error was raised in.
* @param int $line The line number the error was raised at.
* @param array $context Contains an array of every variable that existed in the scope the error was triggered in.
*/
public function onError($code, $message, $file, $line, array $context)
{
if (error_reporting()) {
$this->logger->critical($message, ['error' => new Error($message, $line, $file, debug_backtrace(), $context)]);
$this->showNiceError();
}
}
示例6: setDeployment
/**
* Performs the request to make the deployment
*
* @param string $description
* @param bool $change
* @param bool $user
*
* @return bool|string
*/
public function setDeployment($description, $change = false, $user = false)
{
$apiUrl = $this->config->getNewRelicApiUrl();
if (empty($apiUrl)) {
$this->logger->notice('New Relic API URL is blank, using fallback URL');
$apiUrl = self::API_URL;
}
/** @var \Magento\Framework\HTTP\ZendClient $client */
$client = $this->clientFactory->create();
$client->setUri($apiUrl);
$client->setMethod(ZendClient::POST);
$client->setHeaders(['x-api-key' => $this->config->getNewRelicApiKey()]);
$params = ['deployment[app_name]' => $this->config->getNewRelicAppName(), 'deployment[application_id]' => $this->config->getNewRelicAppId(), 'deployment[description]' => $description, 'deployment[changelog]' => $change, 'deployment[user]' => $user];
$client->setParameterPost($params);
try {
$response = $client->request();
} catch (\Zend_Http_Client_Exception $e) {
$this->logger->critical($e);
return false;
}
if ($response->getStatus() < 200 || $response->getStatus() > 210) {
$this->logger->warning('Deployment marker request did not send a 200 status code.');
return false;
}
return $response->getBody();
}
示例7: addDomainJob
/**
* Method to run a domain job whose workload is a serialized JobRequestInterface
*
* @param \GearmanJob $job Object with job parameters
*
* @throws \Ice\Domain\Jobs\UnsupportedJobException
* @throws \Exception re-throw uncaught exceptions
* @return boolean
*
* @Gearman\Job(
* iterations = 1,
* name = "addDomainJob",
* description = "Data should be an json-encoded object containing at least a 'name' property. That domain job wll be executed"
* )
*/
public function addDomainJob($job)
{
$jobRequest = $this->requestSerializer->deserializeJobRequest($job->workload());
if ($this->logger) {
$this->logger->notice("Job received", [$job->workload()]);
}
if (!$this->director->hasWorkerProviderFor($jobRequest->getName())) {
if ($this->logger) {
$this->logger->critical("No worker available for job of name: " . $jobRequest->getName(), [$job->workload()]);
}
throw new UnsupportedJobException("No worker available for job of name: " . $jobRequest->getName());
}
$worker = $this->director->getWorkerProviderFor($jobRequest->getName())->getWorkerFor($jobRequest->getName());
try {
if ($this->eventDispatcher) {
$this->eventDispatcher->dispatch('ice.job.pre_execute');
}
$worker->execute($jobRequest);
if ($this->logger) {
$this->logger->notice("Job complete", [$job->workload()]);
}
} catch (\Exception $e) {
if ($this->logger) {
$this->logger->critical("Uncaught exception when processing job", array('workload' => $job->workload(), 'message' => $e->getMessage(), 'stack_trace' => $e->getTrace(), 'exception' => $e));
}
//Re-throw the exception anyway, so that gearman knows the job has failed.
throw $e;
}
return true;
}
示例8: aroundDispatch
/**
* Replace standard admin login form with HTTP Basic authentication
*
* @param AbstractAction $subject
* @param callable $proceed
* @param RequestInterface $request
* @return ResponseInterface
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function aroundDispatch(AbstractAction $subject, \Closure $proceed, RequestInterface $request)
{
$resource = isset($this->aclResources[$request->getControllerName()]) ? isset($this->aclResources[$request->getControllerName()][$request->getActionName()]) ? $this->aclResources[$request->getControllerName()][$request->getActionName()] : $this->aclResources[$request->getControllerName()] : null;
$type = $request->getParam('type');
$resourceType = isset($this->aclResources[$type]) ? $this->aclResources[$type] : null;
if (!$resource || !$resourceType) {
return parent::aroundDispatch($subject, $proceed, $request);
}
$session = $this->_auth->getAuthStorage();
// Try to login using HTTP-authentication
if (!$session->isLoggedIn()) {
list($login, $password) = $this->httpAuthentication->getCredentials();
try {
$this->_auth->login($login, $password);
} catch (AuthenticationException $e) {
$this->logger->critical($e);
}
}
// Verify if logged in and authorized
if (!$session->isLoggedIn() || !$this->authorization->isAllowed($resource) || !$this->authorization->isAllowed($resourceType)) {
$this->httpAuthentication->setAuthenticationFailed('RSS Feeds');
return $this->_response;
}
return parent::aroundDispatch($subject, $proceed, $request);
}
示例9: execute
/**
* @return void
*/
public function execute()
{
foreach ($this->schedule as $i => $action) {
$task = $this->getTask($this->schedule[$i]['action']);
if (empty($task)) {
$this->schedule[$i]['lastExecuted'] = date(\DateTime::ATOM);
$this->schedule[$i]['executeCount'] = 0;
$this->insertTask($this->schedule[$i]);
} else {
$this->schedule[$i] = array_merge($this->schedule[$i], $task);
}
}
$startTime = microtime(true);
try {
$this->logger->debug('Schedule starting');
foreach ($this->schedule as $i => $action) {
$nextExecute = Date::getDateTime($this->schedule[$i]['lastExecuted']);
$nextExecute->modify('+' . $this->schedule[$i]['frequency'] . ' ' . $this->schedule[$i]['period']);
if (time() > $nextExecute->getTimestamp()) {
$this->schedule[$i]['executeCount'] = intval($this->schedule[$i]['executeCount']) + 1;
$this->schedule[$i]['lastExecuted'] = date(\DateTime::ATOM);
$this->updateTask($this->schedule[$i]);
$this->executeTask($this->schedule[$i]);
}
}
$this->logger->debug('Schedule complete');
} catch (Exception $e) {
$this->logger->error($e->getMessage());
} catch (\Exception $e) {
$this->logger->critical($e->getMessage());
}
$this->logger->debug('Completed in ' . (microtime(true) - $startTime) . ' seconds');
}
示例10: getFilters
/**
* @param \Magento\Catalog\Model\Layer $layer
* @return array|\Magento\Catalog\Model\Layer\Filter\AbstractFilter[]
*/
public function getFilters(\Magento\Catalog\Model\Layer $layer)
{
try {
if ($this->bxHelperData->isFilterLayoutEnabled($layer) && $this->bxHelperData->isLeftFilterEnabled()) {
$filters = array();
$facets = $this->getBxFacets();
if ($facets) {
foreach ($this->bxHelperData->getLeftFacetFieldNames() as $fieldName) {
$attribute = $this->objectManager->create("Magento\\Catalog\\Model\\ResourceModel\\Eav\\Attribute");
$filter = $this->objectManager->create("Boxalino\\Intelligence\\Model\\Attribute", ['data' => ['attribute_model' => $attribute], 'layer' => $layer]);
$filter->setFacets($facets);
$filter->setFieldName($fieldName);
$filters[] = $filter;
}
}
return $filters;
} else {
return parent::getFilters($layer);
}
} catch (\Exception $e) {
$this->bxHelperData->setFallback(true);
$this->_logger->critical($e);
return parent::getFilters($layer);
}
}
示例11: execute
/**
* Get associated grouped products grid popup
*
* @return void
*/
public function execute()
{
$productId = (int) $this->getRequest()->getParam('id');
/** @var $product \Magento\Catalog\Model\Product */
$product = $this->factory->create();
$product->setStoreId($this->getRequest()->getParam('store', 0));
$typeId = $this->getRequest()->getParam('type');
if (!$productId && $typeId) {
$product->setTypeId($typeId);
}
$product->setData('_edit_mode', true);
if ($productId) {
try {
$product->load($productId);
} catch (\Exception $e) {
$product->setTypeId(\Magento\Catalog\Model\Product\Type::DEFAULT_TYPE);
$this->logger->critical($e);
}
}
$setId = (int) $this->getRequest()->getParam('set');
if ($setId) {
$product->setAttributeSetId($setId);
}
$this->registry->register('current_product', $product);
$this->_view->loadLayout(false);
$this->_view->renderLayout();
}
示例12: afterSave
/**
* Save uploaded file and set its name to category
*
* @param \Magento\Framework\DataObject $object
* @return \Magento\Catalog\Model\Category\Attribute\Backend\Image
*/
public function afterSave($object)
{
$value = $object->getData($this->getAttribute()->getName() . '_additional_data');
// if no image was set - nothing to do
if (empty($value) && empty($_FILES)) {
return $this;
}
if (is_array($value) && !empty($value['delete'])) {
$object->setData($this->getAttribute()->getName(), '');
$this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getName());
return $this;
}
$path = $this->_filesystem->getDirectoryRead(DirectoryList::MEDIA)->getAbsolutePath('catalog/category/');
try {
/** @var $uploader \Magento\MediaStorage\Model\File\Uploader */
$uploader = $this->_fileUploaderFactory->create(['fileId' => $this->getAttribute()->getName()]);
$uploader->setAllowedExtensions(['jpg', 'jpeg', 'gif', 'png']);
$uploader->setAllowRenameFiles(true);
$result = $uploader->save($path);
$object->setData($this->getAttribute()->getName(), $result['file']);
$this->getAttribute()->getEntity()->saveAttribute($object, $this->getAttribute()->getName());
} catch (\Exception $e) {
if ($e->getCode() != \Magento\MediaStorage\Model\File\Uploader::TMP_NAME_EMPTY) {
$this->_logger->critical($e);
}
}
return $this;
}
示例13: afterRead
/**
* @param \Magento\Framework\HTTP\Adapter\Curl $subject
* @param $result
* @return mixed
*/
public function afterRead(\Magento\Framework\HTTP\Adapter\Curl $subject, $result)
{
try {
/* @var $curlLog \Foggyline\Sentinel\Model\CurlLog */
$curlLog = $this->curlLog->create();
$curlLog->setRequestId($this->helper->getHttpRequestUniqueId());
$curlLog->setResult($result);
$curlLog->setMethod($this->cUrlMethod);
$curlLog->setUrl($this->cUrlUrl);
$curlLog->setHttpVer($this->cUrlHttpVer);
$curlLog->setHeaders(serialize($this->cUrlHeaders));
$curlLog->setBody($this->cUrlBody);
$curlLog->setHttpCode($subject->getInfo(CURLINFO_HTTP_CODE));
$curlLog->setTotalTime($subject->getInfo(CURLINFO_TOTAL_TIME));
$curlLog->setNameLookupTime($subject->getInfo(CURLINFO_NAMELOOKUP_TIME));
$curlLog->setPrimaryIp($subject->getInfo(CURLINFO_PRIMARY_IP));
$curlLog->setPrimaryPort($subject->getInfo(CURLINFO_PRIMARY_PORT));
$curlLog->setLocalIp($subject->getInfo(CURLINFO_LOCAL_IP));
$curlLog->setLocalPort($subject->getInfo(CURLINFO_LOCAL_PORT));
$curlLog->setSizeUpload($subject->getInfo(CURLINFO_SIZE_UPLOAD));
$curlLog->setSizeDownload($subject->getInfo(CURLINFO_SIZE_DOWNLOAD));
$curlLog->setSpeedUpload($subject->getInfo(CURLINFO_SPEED_UPLOAD));
$curlLog->setSpeedDownload($subject->getInfo(CURLINFO_SPEED_DOWNLOAD));
$curlLog->setContentType($subject->getInfo(CURLINFO_CONTENT_TYPE));
$curlLog->save();
} catch (\Exception $e) {
$this->logger->critical($e);
}
return $result;
}
示例14: execute
/**
* Order Cancel
*
* @return void
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function execute()
{
$isEnabled = $this->helper->isEnabled();
if ($isEnabled) {
$statuses = $this->helper->getOrderStatuses();
$olderThan = $this->helper->getOlderThan();
$recentThan = $this->helper->getRecentThan();
$comment = $this->helper->getComment();
$orders = $this->orderCollectionFactory->create();
$orders->addFieldToFilter('status', ['in' => $statuses]);
$orders->getSelect()->where(new \Zend_Db_Expr('TIME_TO_SEC(TIMEDIFF(CURRENT_TIMESTAMP, `updated_at`)) >= ' . $olderThan * 60));
$orders->getSelect()->where(new \Zend_Db_Expr('TIME_TO_SEC(TIMEDIFF(CURRENT_TIMESTAMP, `updated_at`)) <= ' . $recentThan * 60));
$orders->getSelect()->limit(10);
$orders->setOrder('entity_id', 'DESC');
foreach ($orders->getItems() as $order) {
if (!$order->canCancel()) {
continue;
}
try {
$order->cancel();
$order->addStatusHistoryComment($comment)->setIsCustomerNotified(false);
$order->save();
} catch (\Exception $e) {
$this->logger->critical($e);
}
}
}
}
示例15: filter
public function filter($tempMinifiedFilename)
{
$originalFilename = $this->srcFile->getPath();
$jarPath = $this->externalLibPath . '/closurecompiler/compiler.jar';
$command = "java -jar {$jarPath} --warning_level QUIET --language_in ECMASCRIPT5 --compilation_level SIMPLE_OPTIMIZATIONS --js {$originalFilename} --js_output_file {$tempMinifiedFilename}";
//SIMPLE_OPTIMIZATIONS
//ADVANCED_OPTIMIZATIONS
//java -jar compiler.jar --compilation_level ADVANCED_OPTIMIZATIONS --js hello.js
$output = system($command, $returnValue);
if ($returnValue != 0) {
@unlink($tempMinifiedFilename);
$logging = "command is {$command} <br/>";
$logging .= "curr dir " . getcwd() . "<br/>";
$logging .= "returnValue {$returnValue} <br/>";
$logging .= "result is: ";
$logging .= "Output is: " . $output . "<br/>";
$this->logger->critical("Failed to generate minified Javascript: " . $logging);
header("Content-type: text/javascript");
header("Cache-Control: no-cache, must-revalidate");
// HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
// Date in the past
echo "alert('Javacript not generated. Someone please tell the server dude \"{$originalFilename}\" failed.')";
exit(0);
}
}