本文整理汇总了PHP中TYPO3\Flow\Log\SystemLoggerInterface::logException方法的典型用法代码示例。如果您正苦于以下问题:PHP SystemLoggerInterface::logException方法的具体用法?PHP SystemLoggerInterface::logException怎么用?PHP SystemLoggerInterface::logException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\Flow\Log\SystemLoggerInterface
的用法示例。
在下文中一共展示了SystemLoggerInterface::logException方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* Provides an XML comment containing the exception
*
* @param string $typoScriptPath path causing the exception
* @param \Exception $exception exception to handle
* @param integer $referenceCode
* @return string
*/
protected function handle($typoScriptPath, \Exception $exception, $referenceCode)
{
$this->systemLogger->logException($exception);
if (isset($referenceCode)) {
return sprintf('<!-- Exception while rendering %s: %s (%s) -->', $this->formatScriptPath($typoScriptPath, ''), htmlspecialchars($exception->getMessage()), $referenceCode);
} else {
return sprintf('<!-- Exception while rendering %s: %s -->', $this->formatScriptPath($typoScriptPath, ''), htmlspecialchars($exception->getMessage()));
}
}
示例2: newSiteCommand
/**
* Create a new site from a site template
*
* This command uses a site template located in a sitePackage to create a new site with a new subdomain.
*
* @param string $sitePackage Package key of the Site containing the template under Templates/Content/Sites.xml
* @param string $siteName The sitename
* @param string $baseDomain The base domain name e.g. site.com => will be used like $siteName.site.com
* @return void
*/
public function newSiteCommand($sitePackage, $siteName, $baseDomain)
{
try {
$site = $this->siteService->importSiteFromTemplate($sitePackage, $siteName, $baseDomain);
$this->outputLine('Created a new site "%s"', array($site->getName()));
} catch (\Exception $e) {
$this->systemLogger->logException($e);
$this->outputLine('An error occured during site creation, check error log for details');
}
}
示例3: handle
/**
* Renders the exception in HTML for display
*
* @param string $typoScriptPath path causing the exception
* @param \Exception $exception exception to handle
* @param integer $referenceCode
* @return string
*/
protected function handle($typoScriptPath, \Exception $exception, $referenceCode)
{
$messageArray = array('header' => 'An exception was thrown while Neos tried to render your page', 'content' => $exception->getMessage(), 'stacktrace' => $this->formatTypoScriptPath($typoScriptPath), 'referenceCode' => $this->formatErrorCodeMessage($referenceCode));
$messageBody = sprintf('<p class="neos-message-content">%s</p>' . '<p class="neos-message-stacktrace"><code>%s</code></p>', $messageArray['content'], $messageArray['stacktrace']);
if ($referenceCode) {
$messageBody = sprintf('%s<p class="neos-reference-code">%s</p>', $messageBody, $messageArray['referenceCode']);
}
$message = sprintf('<div class="neos-message-header"><div class="neos-message-icon"><i class="icon-warning-sign"></i></div><h1>%s</h1></div>' . '<div class="neos-message-wrapper">%s</div>', $messageArray['header'], $messageBody);
$this->systemLogger->logException($exception);
return $message;
}
示例4: handleException
/**
* Handles the given exception
*
* @param object $exception The exception object - can be \Exception, or some type of \Throwable in PHP 7
* @return void
*/
public function handleException($exception)
{
// Ignore if the error is suppressed by using the shut-up operator @
if (error_reporting() === 0) {
return;
}
$this->renderingOptions = $this->resolveCustomRenderingOptions($exception);
if (is_object($this->systemLogger) && isset($this->renderingOptions['logException']) && $this->renderingOptions['logException']) {
if ($exception instanceof \Throwable) {
if ($this->systemLogger instanceof ThrowableLoggerInterface) {
$this->systemLogger->logThrowable($exception);
} else {
// Convert \Throwable to \Exception for non-supporting logger implementations
$this->systemLogger->logException(new \Exception($exception->getMessage(), $exception->getCode()));
}
} elseif ($exception instanceof \Exception) {
$this->systemLogger->logException($exception);
}
}
switch (PHP_SAPI) {
case 'cli':
$this->echoExceptionCli($exception);
break;
default:
$this->echoExceptionWeb($exception);
}
}
示例5: persistAll
/**
* Commits new objects and changes to objects in the current persistence
* session into the backend
*
* @param boolean $onlyWhitelistedObjects If TRUE an exception will be thrown if there are scheduled updates/deletes or insertions for objects that are not "whitelisted" (see AbstractPersistenceManager::whitelistObject())
* @return void
* @api
*/
public function persistAll($onlyWhitelistedObjects = false)
{
if ($onlyWhitelistedObjects) {
$unitOfWork = $this->entityManager->getUnitOfWork();
/** @var \Doctrine\ORM\UnitOfWork $unitOfWork */
$unitOfWork->computeChangeSets();
$objectsToBePersisted = $unitOfWork->getScheduledEntityUpdates() + $unitOfWork->getScheduledEntityDeletions() + $unitOfWork->getScheduledEntityInsertions();
foreach ($objectsToBePersisted as $object) {
$this->throwExceptionIfObjectIsNotWhitelisted($object);
}
}
if (!$this->entityManager->isOpen()) {
$this->systemLogger->log('persistAll() skipped flushing data, the Doctrine EntityManager is closed. Check the logs for error message.', LOG_ERR);
return;
}
try {
$this->entityManager->flush();
} catch (Exception $exception) {
$this->systemLogger->logException($exception);
/** @var Connection $connection */
$connection = $this->entityManager->getConnection();
$connection->close();
$connection->connect();
$this->systemLogger->log('Reconnected the Doctrine EntityManager to the persistence backend.', LOG_INFO);
$this->entityManager->flush();
} finally {
$this->emitAllObjectsPersisted();
}
}
示例6: sendNewCommentNotification
/**
* Send a new notification that a comment has been created
*
* @param \TYPO3\TYPO3CR\Domain\Model\NodeInterface $commentNode The comment node
* @param \TYPO3\TYPO3CR\Domain\Model\NodeInterface $postNode The post node
* @return void
*/
public function sendNewCommentNotification(NodeInterface $commentNode, NodeInterface $postNode)
{
if ($this->settings['notifications']['to']['email'] === '') {
return;
}
if (!class_exists('TYPO3\\SwiftMailer\\Message')) {
$this->systemLogger->logException(new \TYPO3\Flow\Exception('The package "TYPO3.SwiftMailer" is required to send notifications!', 1359473932));
return;
}
try {
$mail = new Message();
$mail->setFrom(array($commentNode->getProperty('emailAddress') => $commentNode->getProperty('author')))->setTo(array($this->settings['notifications']['to']['email'] => $this->settings['notifications']['to']['name']))->setSubject('New comment on blog post "' . $postNode->getProperty('title') . '"' . ($commentNode->getProperty('spam') ? ' (SPAM)' : ''))->setBody($commentNode->getProperty('text'))->send();
} catch (\Exception $e) {
$this->systemLogger->logException($e);
}
}
示例7: importSite
/**
* @param \TYPO3\Form\Core\Model\FinisherContext $finisherContext
* @return void
* @throws \TYPO3\Setup\Exception
*/
public function importSite(\TYPO3\Form\Core\Model\FinisherContext $finisherContext)
{
$formValues = $finisherContext->getFormRuntime()->getFormState()->getFormValues();
if (isset($formValues['prune']) && intval($formValues['prune']) === 1) {
$this->nodeDataRepository->removeAll();
$this->workspaceRepository->removeAll();
$this->domainRepository->removeAll();
$this->siteRepository->removeAll();
$this->persistenceManager->persistAll();
}
if (!empty($formValues['packageKey'])) {
if ($this->packageManager->isPackageAvailable($formValues['packageKey'])) {
throw new \TYPO3\Setup\Exception(sprintf('The package key "%s" already exists.', $formValues['packageKey']), 1346759486);
}
$packageKey = $formValues['packageKey'];
$siteName = $formValues['siteName'];
$generatorService = $this->objectManager->get('TYPO3\\Neos\\Kickstarter\\Service\\GeneratorService');
$generatorService->generateSitePackage($packageKey, $siteName);
} elseif (!empty($formValues['site'])) {
$packageKey = $formValues['site'];
}
$this->deactivateOtherSitePackages($packageKey);
$this->packageManager->activatePackage($packageKey);
if (!empty($packageKey)) {
try {
$contentContext = $this->contextFactory->create(array('workspaceName' => 'live'));
$this->siteImportService->importFromPackage($packageKey, $contentContext);
} catch (\Exception $exception) {
$finisherContext->cancel();
$this->systemLogger->logException($exception);
throw new SetupException(sprintf('Error: During the import of the "Sites.xml" from the package "%s" an exception occurred: %s', $packageKey, $exception->getMessage()), 1351000864);
}
}
}
示例8: importCommand
/**
* Import sites content
*
* This command allows for importing one or more sites or partial content from an XML source. The format must
* be identical to that produced by the export command.
*
* If a filename is specified, this command expects the corresponding file to contain the XML structure. The
* filename php://stdin can be used to read from standard input.
*
* If a package key is specified, this command expects a Sites.xml file to be located in the private resources
* directory of the given package (Resources/Private/Content/Sites.xml).
*
* @param string $packageKey Package key specifying the package containing the sites content
* @param string $filename relative path and filename to the XML file containing the sites content
* @return void
*/
public function importCommand($packageKey = null, $filename = null)
{
$exceedingArguments = $this->request->getExceedingArguments();
if (isset($exceedingArguments[0]) && $packageKey === null && $filename === null) {
if (file_exists($exceedingArguments[0])) {
$filename = $exceedingArguments[0];
} elseif ($this->packageManager->isPackageAvailable($exceedingArguments[0])) {
$packageKey = $exceedingArguments[0];
}
}
if ($packageKey === null && $filename === null) {
$this->outputLine('You have to specify either "--package-key" or "--filename"');
$this->quit(1);
}
$site = null;
if ($filename !== null) {
try {
$site = $this->siteImportService->importFromFile($filename);
} catch (\Exception $exception) {
$this->systemLogger->logException($exception);
$this->outputLine('Error: During the import of the file "%s" an exception occurred: %s, see log for further information.', array($filename, $exception->getMessage()));
$this->quit(1);
}
} else {
try {
$site = $this->siteImportService->importFromPackage($packageKey);
} catch (\Exception $exception) {
$this->systemLogger->logException($exception);
$this->outputLine('Error: During the import of the "Sites.xml" from the package "%s" an exception occurred: %s, see log for further information.', array($packageKey, $exception->getMessage()));
$this->quit(1);
}
}
$this->outputLine('Import of site "%s" finished.', array($site->getName()));
}
示例9: createSiteAction
/**
* Create a new site.
*
* @param string $site Site to import
* @param string $packageKey Package Name to create
* @param string $siteName Site Name to create
* @Flow\Validate(argumentName="$packageKey", type="\TYPO3\Neos\Validation\Validator\PackageKeyValidator")
* @return void
*/
public function createSiteAction($site, $packageKey = '', $siteName = '')
{
if ($packageKey !== '' && $this->packageManager->isPackageActive('TYPO3.Neos.Kickstarter')) {
if ($this->packageManager->isPackageAvailable($packageKey)) {
$this->addFlashMessage('The package key "%s" already exists.', 'Invalid package key', Message::SEVERITY_ERROR, array(htmlspecialchars($packageKey)), 1412372021);
$this->redirect('index');
}
$generatorService = $this->objectManager->get('TYPO3\\Neos\\Kickstarter\\Service\\GeneratorService');
$generatorService->generateSitePackage($packageKey, $siteName);
} else {
$packageKey = $site;
}
$deactivatedSitePackages = $this->deactivateAllOtherSitePackages($packageKey);
if (count($deactivatedSitePackages) > 0) {
$this->flashMessageContainer->addMessage(new Message(sprintf('The existing Site Packages "%s" were deactivated, in order to prevent interactions with the newly created package "%s".', htmlspecialchars(implode(', ', $deactivatedSitePackages)), htmlspecialchars($packageKey))));
}
$this->packageManager->activatePackage($packageKey);
if ($packageKey !== '') {
try {
$this->siteImportService->importFromPackage($packageKey);
$this->addFlashMessage('The site has been created.', '', null, array(), 1412372266);
} catch (\Exception $exception) {
$this->systemLogger->logException($exception);
$this->addFlashMessage('Error: During the import of the "Sites.xml" from the package "%s" an exception occurred: %s', 'Import error', Message::SEVERITY_ERROR, array(htmlspecialchars($packageKey), htmlspecialchars($exception->getMessage())), 1412372375);
}
} else {
$this->addFlashMessage('No site selected for import and no package name provided.', 'No site selected', Message::SEVERITY_ERROR, array(), 1412372554);
$this->redirect('newSite');
}
$this->unsetLastVisitedNodeAndRedirect('index');
}
示例10: count
/**
* Returns the query result count
*
* @return integer The query result count
* @throws Exception\DatabaseConnectionException
* @api
*/
public function count()
{
try {
$originalQuery = $this->queryBuilder->getQuery();
$dqlQuery = clone $originalQuery;
$dqlQuery->setParameters($originalQuery->getParameters());
$dqlQuery->setHint(\Doctrine\ORM\Query::HINT_CUSTOM_TREE_WALKERS, array('TYPO3\\Flow\\Persistence\\Doctrine\\CountWalker'));
$offset = $dqlQuery->getFirstResult();
$limit = $dqlQuery->getMaxResults();
if ($offset !== NULL) {
$dqlQuery->setFirstResult(NULL);
}
$numberOfResults = (int) $dqlQuery->getSingleScalarResult();
if ($offset !== NULL) {
$numberOfResults = max(0, $numberOfResults - $offset);
}
if ($limit !== NULL) {
$numberOfResults = min($numberOfResults, $limit);
}
return $numberOfResults;
} catch (\Doctrine\ORM\ORMException $ormException) {
$this->systemLogger->logException($ormException);
return 0;
} catch (\PDOException $pdoException) {
throw new Exception\DatabaseConnectionException($pdoException->getMessage(), $pdoException->getCode());
}
}
示例11: handleException
/**
* Handles the given exception
*
* @param \Exception $exception The exception object
* @return void
*/
public function handleException(\Exception $exception)
{
// Ignore if the error is suppressed by using the shut-up operator @
if (error_reporting() === 0) {
return;
}
if (is_object($this->systemLogger)) {
$this->systemLogger->logException($exception);
}
switch (PHP_SAPI) {
case 'cli':
$this->echoExceptionCli($exception);
break;
default:
$this->echoExceptionWeb($exception);
}
}
示例12: handleException
/**
* Output an error message and log the exception.
*
* @param \Exception $exception
* @return void
*/
protected function handleException(\Exception $exception)
{
$this->outputLine('<error>%s</error>', [$exception->getMessage()]);
$this->outputLine();
$this->outputLine('The exception details have been logged to the Flow system log.');
$this->systemLogger->logException($exception);
$this->quit(1);
}
示例13: sendMail
/**
* Sends a mail and creates a system logger entry if sending failed
*
* @param Message $mail
* @return boolean TRUE on success, otherwise FALSE
*/
protected function sendMail(Message $mail)
{
$numberOfRecipients = 0;
// ignore exceptions but log them
$exceptionMessage = '';
try {
$numberOfRecipients = $mail->send();
} catch (\Exception $e) {
$this->systemLogger->logException($e);
$exceptionMessage = $e->getMessage();
}
if ($numberOfRecipients < 1) {
$this->systemLogger->log('Could not send notification email "' . $mail->getSubject() . '"', LOG_ERR, ['exception' => $exceptionMessage, 'message' => $mail->getSubject(), 'id' => (string) $mail->getHeaders()->get('Message-ID')]);
return false;
}
return true;
}
示例14: handleException
/**
* Return an array with data from the given exception, suitable for being returned
* in an ExtDirect response.
*
* The excpetion is logged to the system logger as well.
*
* @param \Exception $exception
* @return array
*/
protected function handleException(\Exception $exception, $transactionId = NULL)
{
$this->systemLogger->logException($exception);
// As an exception happened, we now need to check whether detailed exception reporting was enabled.
$exposeExceptionInformation = $this->settings['ExtDirect']['exposeExceptionInformation'] === TRUE;
$exceptionWhere = $exception instanceof \TYPO3\Flow\Exception ? ' (ref ' . $exception->getReferenceCode() . ')' : '';
$exceptionMessage = $exposeExceptionInformation ? 'Uncaught exception #' . $exception->getCode() . $exceptionWhere . ' - ' . $exception->getMessage() : 'An internal error occured';
return array('type' => 'exception', 'tid' => $transactionId, 'message' => $exceptionMessage, 'where' => $exceptionWhere);
}
示例15: getProperty
/**
* Get a single property reduced to a simple type (no objects) representation
*
* @param NodeInterface $node
* @param string $propertyName
* @return mixed
*/
public function getProperty(NodeInterface $node, $propertyName)
{
if ($propertyName[0] === '_') {
$propertyValue = ObjectAccess::getProperty($node, ltrim($propertyName, '_'));
} else {
$propertyValue = $node->getProperty($propertyName);
}
$dataType = $node->getNodeType()->getPropertyType($propertyName);
try {
$convertedValue = $this->convertValue($propertyValue, $dataType);
} catch (PropertyException $exception) {
$this->systemLogger->logException($exception);
$convertedValue = null;
}
if ($convertedValue === null) {
$convertedValue = $this->getDefaultValueForProperty($node->getNodeType(), $propertyName);
}
return $convertedValue;
}