当前位置: 首页>>代码示例>>PHP>>正文


PHP ILogger::logException方法代码示例

本文整理汇总了PHP中OCP\ILogger::logException方法的典型用法代码示例。如果您正苦于以下问题:PHP ILogger::logException方法的具体用法?PHP ILogger::logException怎么用?PHP ILogger::logException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OCP\ILogger的用法示例。


在下文中一共展示了ILogger::logException方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: runScanner

 /**
  * @param IUser $user
  */
 protected function runScanner(IUser $user)
 {
     try {
         $scanner = new Scanner($user->getUID(), $this->dbConnection, $this->logger);
         $scanner->backgroundScan('');
     } catch (\Exception $e) {
         $this->logger->logException($e, ['app' => 'files']);
     }
     \OC_Util::tearDownFS();
 }
开发者ID:loulancn,项目名称:core,代码行数:13,代码来源:scanfiles.php

示例2: testDetectcheckPassword

 /**
  * @dataProvider userAndPasswordData
  */
 public function testDetectcheckPassword($user, $password)
 {
     $e = new \Exception('test');
     $this->logger->logException($e);
     $logLines = $this->getLogs();
     foreach ($logLines as $logLine) {
         $this->assertNotContains($user, $logLine);
         $this->assertNotContains($password, $logLine);
         $this->assertContains('checkPassword(*** username and password replaced ***)', $logLine);
     }
 }
开发者ID:evanjt,项目名称:core,代码行数:14,代码来源:logger.php

示例3: migrateCalendar

 /**
  * @param int $calendarId
  * @param int $newCalendarId
  */
 private function migrateCalendar($calendarId, $newCalendarId)
 {
     $this->adapter->foreachCalendarObject($calendarId, function ($calObject) use($newCalendarId) {
         try {
             $this->backend->createCalendarObject($newCalendarId, $calObject['uri'], $calObject['calendardata']);
         } catch (\Exception $ex) {
             $eventId = $calObject['id'];
             $calendarId = $calObject['calendarId'];
             $msg = "One event could not be migrated. (id: {$eventId}, calendarid: {$calendarId})";
             $this->logger->logException($ex, ['app' => 'dav', 'message' => $msg]);
             if (!is_null($this->consoleOutput)) {
                 $this->consoleOutput->writeln($msg);
             }
         }
     });
 }
开发者ID:gvde,项目名称:core,代码行数:20,代码来源:migratecalendars.php

示例4: run

 protected function run($argument)
 {
     $target = $argument['url'];
     $source = $this->urlGenerator->getAbsoluteURL('/');
     $source = rtrim($source, '/');
     $token = $argument['token'];
     try {
         $result = $this->httpClient->post($target . $this->endPoint, ['body' => ['url' => $source, 'token' => $token], 'timeout' => 3, 'connect_timeout' => 3]);
         $status = $result->getStatusCode();
     } catch (ClientException $e) {
         $status = $e->getCode();
         $this->logger->logException($e);
     } catch (\Exception $e) {
         $status = HTTP::STATUS_INTERNAL_SERVER_ERROR;
         $this->logger->logException($e);
     }
     // if we received a unexpected response we try again later
     if ($status !== Http::STATUS_OK && $status !== Http::STATUS_FORBIDDEN) {
         $this->jobList->add('OCA\\Federation\\BackgroundJob\\RequestSharedSecret', $argument);
     }
     if ($status === Http::STATUS_FORBIDDEN) {
         // clear token if remote server refuses to ask for shared secret
         $this->dbHandler->addToken($target, '');
     }
 }
开发者ID:farukuzun,项目名称:core-1,代码行数:25,代码来源:requestsharedsecret.php

示例5: scan

 /**
  * @param string $dir
  * @throws \OC\ForbiddenException
  */
 public function scan($dir = '')
 {
     if (!Filesystem::isValidPath($dir)) {
         throw new \InvalidArgumentException('Invalid path to scan');
     }
     $mounts = $this->getMounts($dir);
     foreach ($mounts as $mount) {
         if (is_null($mount->getStorage())) {
             continue;
         }
         $storage = $mount->getStorage();
         // if the home storage isn't writable then the scanner is run as the wrong user
         if ($storage->instanceOfStorage('\\OC\\Files\\Storage\\Home') and (!$storage->isCreatable('') or !$storage->isCreatable('files'))) {
             throw new ForbiddenException();
         }
         $relativePath = $mount->getInternalPath($dir);
         $scanner = $storage->getScanner();
         $scanner->setUseTransactions(false);
         $this->attachListener($mount);
         $isDbLocking = \OC::$server->getLockingProvider() instanceof DBLockingProvider;
         if (!$isDbLocking) {
             $this->db->beginTransaction();
         }
         try {
             $scanner->scan($relativePath, \OC\Files\Cache\Scanner::SCAN_RECURSIVE, \OC\Files\Cache\Scanner::REUSE_ETAG | \OC\Files\Cache\Scanner::REUSE_SIZE);
         } catch (StorageNotAvailableException $e) {
             $this->logger->error('Storage ' . $storage->getId() . ' not available');
             $this->logger->logException($e);
             $this->emit('\\OC\\Files\\Utils\\Scanner', 'StorageNotAvailable', [$e]);
         }
         if (!$isDbLocking) {
             $this->db->commit();
         }
     }
 }
开发者ID:gvde,项目名称:core,代码行数:39,代码来源:scanner.php

示例6: run

 /**
  * @param array $argument
  * @throws \Exception
  * @throws \OC\NeedsUpdateException
  */
 protected function run($argument)
 {
     if (!isset($argument['app']) || !isset($argument['step'])) {
         // remove the job - we can never execute it
         $this->jobList->remove($this, $this->argument);
         return;
     }
     $app = $argument['app'];
     try {
         $this->loadApp($app);
     } catch (NeedsUpdateException $ex) {
         // as long as the app is not yet done with it's offline migration
         // we better not start with the live migration
         return;
     }
     $step = $argument['step'];
     $repair = new Repair([], $this->dispatcher);
     try {
         $repair->addStep($step);
     } catch (\Exception $ex) {
         $this->logger->logException($ex, ['app' => 'migration']);
         // remove the job - we can never execute it
         $this->jobList->remove($this, $this->argument);
         return;
     }
     // execute the repair step
     $repair->run();
     // remove the job once executed successfully
     $this->jobList->remove($this, $this->argument);
 }
开发者ID:GitHubUser4234,项目名称:core,代码行数:35,代码来源:BackgroundRepair.php

示例7: postCroppedAvatar

 /**
  * @NoAdminRequired
  *
  * @param array $crop
  * @return DataResponse
  */
 public function postCroppedAvatar($crop)
 {
     $userId = $this->userSession->getUser()->getUID();
     if (is_null($crop)) {
         return new DataResponse(['data' => ['message' => $this->l->t("No crop data provided")]], Http::STATUS_BAD_REQUEST);
     }
     if (!isset($crop['x'], $crop['y'], $crop['w'], $crop['h'])) {
         return new DataResponse(['data' => ['message' => $this->l->t("No valid crop data provided")]], Http::STATUS_BAD_REQUEST);
     }
     $tmpAvatar = $this->cache->get('tmpAvatar');
     if (is_null($tmpAvatar)) {
         return new DataResponse(['data' => ['message' => $this->l->t("No temporary profile picture available, try again")]], Http::STATUS_BAD_REQUEST);
     }
     $image = new \OC_Image($tmpAvatar);
     $image->crop($crop['x'], $crop['y'], round($crop['w']), round($crop['h']));
     try {
         $avatar = $this->avatarManager->getAvatar($userId);
         $avatar->set($image);
         // Clean up
         $this->cache->remove('tmpAvatar');
         return new DataResponse(['status' => 'success']);
     } catch (\OC\NotSquareException $e) {
         return new DataResponse(['data' => ['message' => $this->l->t('Crop is not square')]], Http::STATUS_BAD_REQUEST);
     } catch (\Exception $e) {
         $this->logger->logException($e, ['app' => 'core']);
         return new DataResponse(['data' => ['message' => $this->l->t('An error occurred. Please contact your admin.')]], Http::STATUS_BAD_REQUEST);
     }
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:34,代码来源:AvatarController.php

示例8: getPhoto

 function getPhoto(Card $node)
 {
     // TODO: this is kind of expensive - load carddav data from database and parse it
     //       we might want to build up a cache one day
     try {
         $vObject = $this->readCard($node->get());
         if (!$vObject->PHOTO) {
             return false;
         }
         $photo = $vObject->PHOTO;
         $type = $this->getType($photo);
         $val = $photo->getValue();
         if ($photo->getValueType() === 'URI') {
             $parsed = \Sabre\URI\parse($val);
             //only allow data://
             if ($parsed['scheme'] !== 'data') {
                 return false;
             }
             if (substr_count($parsed['path'], ';') === 1) {
                 list($type, ) = explode(';', $parsed['path']);
             }
             $val = file_get_contents($val);
         }
         return ['Content-Type' => $type, 'body' => $val];
     } catch (\Exception $ex) {
         $this->logger->logException($ex);
     }
     return false;
 }
开发者ID:GitHubUser4234,项目名称:core,代码行数:29,代码来源:ImageExportPlugin.php

示例9: migrateBook

 /**
  * @param int $addressBookId
  * @param int $newAddressBookId
  */
 private function migrateBook($addressBookId, $newAddressBookId)
 {
     $this->adapter->foreachCard($addressBookId, function ($card) use($newAddressBookId) {
         try {
             $this->backend->createCard($newAddressBookId, $card['uri'], $card['carddata']);
         } catch (\Exception $ex) {
             $eventId = $card['id'];
             $addressBookId = $card['addressbookid'];
             $msg = "One event could not be migrated. (id: {$eventId}, addressbookid: {$addressBookId})";
             $this->logger->logException($ex, ['app' => 'dav', 'message' => $msg]);
             if (!is_null($this->consoleOutput)) {
                 $this->consoleOutput->writeln($msg);
             }
         }
     });
 }
开发者ID:gvde,项目名称:core,代码行数:20,代码来源:migrateaddressbooks.php

示例10: run

 protected function run($argument)
 {
     $target = $argument['url'];
     $source = $this->urlGenerator->getAbsoluteURL('/');
     $source = rtrim($source, '/');
     $token = $argument['token'];
     try {
         $result = $this->httpClient->get($target . $this->endPoint, ['query' => ['url' => $source, 'token' => $token], 'timeout' => 3, 'connect_timeout' => 3]);
         $status = $result->getStatusCode();
     } catch (ClientException $e) {
         $status = $e->getCode();
         $this->logger->logException($e);
     }
     // if we received a unexpected response we try again later
     if ($status !== Http::STATUS_OK && $status !== Http::STATUS_FORBIDDEN) {
         $this->jobList->add('OCA\\Federation\\BackgroundJob\\GetSharedSecret', $argument);
     } else {
         // reset token if we received a valid response
         $this->dbHandler->addToken($target, '');
     }
     if ($status === Http::STATUS_OK) {
         $body = $result->getBody();
         $result = json_decode($body, true);
         if (isset($result['ocs']['data']['sharedSecret'])) {
             $this->trustedServers->addSharedSecret($target, $result['ocs']['data']['sharedSecret']);
         } else {
             $this->logger->error('remote server "' . $target . '"" does not return a valid shared secret', ['app' => 'federation']);
             $this->trustedServers->setServerStatus($target, TrustedServers::STATUS_FAILURE);
         }
     }
 }
开发者ID:Larzenegger,项目名称:owncloud-core,代码行数:31,代码来源:getsharedsecret.php

示例11: createStorage

 /**
  * Create a storage from its parameters
  *
  * @param string $mountPoint storage mount point
  * @param string $backend backend identifier
  * @param string $authMechanism authentication mechanism identifier
  * @param array $backendOptions backend-specific options
  * @param array|null $mountOptions mount-specific options
  * @param array|null $applicableUsers users for which to mount the storage
  * @param array|null $applicableGroups groups for which to mount the storage
  * @param int|null $priority priority
  *
  * @return StorageConfig|DataResponse
  */
 protected function createStorage($mountPoint, $backend, $authMechanism, $backendOptions, $mountOptions = null, $applicableUsers = null, $applicableGroups = null, $priority = null)
 {
     try {
         return $this->service->createStorage($mountPoint, $backend, $authMechanism, $backendOptions, $mountOptions, $applicableUsers, $applicableGroups, $priority);
     } catch (\InvalidArgumentException $e) {
         $this->logger->logException($e);
         return new DataResponse(['message' => (string) $this->l10n->t('Invalid backend or authentication mechanism class')], Http::STATUS_UNPROCESSABLE_ENTITY);
     }
 }
开发者ID:vincchan,项目名称:core,代码行数:23,代码来源:storagescontroller.php

示例12: scan

 /**
  * @param string $dir
  * @throws \OC\ForbiddenException
  */
 public function scan($dir = '')
 {
     if (!Filesystem::isValidPath($dir)) {
         throw new \InvalidArgumentException('Invalid path to scan');
     }
     $mounts = $this->getMounts($dir);
     foreach ($mounts as $mount) {
         if (is_null($mount->getStorage())) {
             continue;
         }
         $storage = $mount->getStorage();
         // if the home storage isn't writable then the scanner is run as the wrong user
         if ($storage->instanceOfStorage('\\OC\\Files\\Storage\\Home') and (!$storage->isCreatable('') or !$storage->isCreatable('files'))) {
             if ($storage->file_exists('') or $storage->getCache()->inCache('')) {
                 throw new ForbiddenException();
             } else {
                 // if the root exists in neither the cache nor the storage the user isn't setup yet
                 break;
             }
         }
         $relativePath = $mount->getInternalPath($dir);
         $scanner = $storage->getScanner();
         $scanner->setUseTransactions(false);
         $this->attachListener($mount);
         $isDbLocking = \OC::$server->getLockingProvider() instanceof DBLockingProvider;
         $scanner->listen('\\OC\\Files\\Cache\\Scanner', 'removeFromCache', function ($path) use($storage) {
             $this->triggerPropagator($storage, $path);
         });
         $scanner->listen('\\OC\\Files\\Cache\\Scanner', 'updateCache', function ($path) use($storage) {
             $this->triggerPropagator($storage, $path);
         });
         $scanner->listen('\\OC\\Files\\Cache\\Scanner', 'addToCache', function ($path) use($storage) {
             $this->triggerPropagator($storage, $path);
         });
         if (!$isDbLocking) {
             $this->db->beginTransaction();
         }
         try {
             $storage->getPropagator()->beginBatch();
             $scanner->scan($relativePath, \OC\Files\Cache\Scanner::SCAN_RECURSIVE, \OC\Files\Cache\Scanner::REUSE_ETAG | \OC\Files\Cache\Scanner::REUSE_SIZE);
             $cache = $storage->getCache();
             if ($cache instanceof Cache) {
                 // only re-calculate for the root folder we scanned, anything below that is taken care of by the scanner
                 $cache->correctFolderSize($relativePath);
             }
             $storage->getPropagator()->commitBatch();
         } catch (StorageNotAvailableException $e) {
             $this->logger->error('Storage ' . $storage->getId() . ' not available');
             $this->logger->logException($e);
             $this->emit('\\OC\\Files\\Utils\\Scanner', 'StorageNotAvailable', [$e]);
         }
         if (!$isDbLocking) {
             $this->db->commit();
         }
     }
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:60,代码来源:Scanner.php

示例13: generate

 /**
  * Generate url based on $name and $parameters
  *
  * @param string $name Name of the route to use.
  * @param array $parameters Parameters for the route
  * @param bool $absolute
  * @return string
  */
 public function generate($name, $parameters = array(), $absolute = false)
 {
     $this->loadRoutes();
     try {
         return $this->getGenerator()->generate($name, $parameters, $absolute);
     } catch (RouteNotFoundException $e) {
         $this->logger->logException($e);
         return '';
     }
 }
开发者ID:DaubaKao,项目名称:owncloud-core,代码行数:18,代码来源:router.php

示例14: execute

 /**
  * @param JobList $jobList
  * @param ILogger $logger
  */
 public function execute($jobList, ILogger $logger = null)
 {
     $jobList->setLastRun($this);
     try {
         $this->run($this->argument);
     } catch (\Exception $e) {
         if ($logger) {
             $logger->logException($e, ['app' => 'core', 'message' => 'Error while running background job (class: ' . get_class($this) . ', arguments: ' . print_r($this->argument, true) . ')']);
         }
     }
 }
开发者ID:GitHubUser4234,项目名称:core,代码行数:15,代码来源:Job.php

示例15: updateComment

 /**
  * update the comment's message
  *
  * @param $propertyValue
  * @return bool
  */
 public function updateComment($propertyValue)
 {
     try {
         $this->comment->setMessage($propertyValue);
         $this->commentsManager->save($this->comment);
         return true;
     } catch (\Exception $e) {
         $this->logger->logException($e, ['app' => 'dav/comments']);
         return false;
     }
 }
开发者ID:Pookay,项目名称:core,代码行数:17,代码来源:commentnode.php


注:本文中的OCP\ILogger::logException方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。