本文整理汇总了PHP中OCP\ILogger类的典型用法代码示例。如果您正苦于以下问题:PHP ILogger类的具体用法?PHP ILogger怎么用?PHP ILogger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ILogger类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: 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
示例2: 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->error('Error while running background job: ' . $e->getMessage());
}
}
}
开发者ID:Angelos0,项目名称:core,代码行数:15,代码来源:job.php
示例3: syncRemoteAddressBook
/**
* @param string $url
* @param string $userName
* @param string $sharedSecret
* @param string $syncToken
* @param int $targetBookId
* @param string $targetPrincipal
* @param array $targetProperties
* @return string
* @throws \Exception
*/
public function syncRemoteAddressBook($url, $userName, $sharedSecret, $syncToken, $targetBookId, $targetPrincipal, $targetProperties)
{
// 1. create addressbook
$book = $this->ensureSystemAddressBookExists($targetPrincipal, $targetBookId, $targetProperties);
$addressBookId = $book['id'];
// 2. query changes
try {
$response = $this->requestSyncReport($url, $userName, $sharedSecret, $syncToken);
} catch (ClientHttpException $ex) {
if ($ex->getCode() === Http::STATUS_UNAUTHORIZED) {
// remote server revoked access to the address book, remove it
$this->backend->deleteAddressBook($addressBookId);
$this->logger->info('Authorization failed, remove address book: ' . $url, ['app' => 'dav']);
throw $ex;
}
}
// 3. apply changes
// TODO: use multi-get for download
foreach ($response['response'] as $resource => $status) {
$cardUri = basename($resource);
if (isset($status[200])) {
$vCard = $this->download($url, $sharedSecret, $resource);
$existingCard = $this->backend->getCard($addressBookId, $cardUri);
if ($existingCard === false) {
$this->backend->createCard($addressBookId, $cardUri, $vCard['body']);
} else {
$this->backend->updateCard($addressBookId, $cardUri, $vCard['body']);
}
} else {
$this->backend->deleteCard($addressBookId, $cardUri);
}
}
return $response['token'];
}
开发者ID:stweil,项目名称:owncloud-core,代码行数:45,代码来源:syncservice.php
示例4: cleanUserTags
/**
* Deleting orphaned user tag mappings
*
* @return int Number of deleted entries
*/
protected function cleanUserTags()
{
$subQuery = $this->connection->getQueryBuilder();
$subQuery->select($subQuery->expr()->literal('1'))->from('filecache', 'f')->where($subQuery->expr()->eq('objid', 'f.fileid'));
$query = $this->connection->getQueryBuilder();
$deletedEntries = $query->delete('vcategory_to_object')->where($query->expr()->eq('type', $query->expr()->literal('files')))->andWhere($query->expr()->isNull($query->createFunction('(' . $subQuery->getSql() . ')')))->execute();
$this->logger->debug("{$deletedEntries} orphaned user tag relations deleted", ['app' => 'DeleteOrphanedTagsJob']);
return $deletedEntries;
}
开发者ID:matthias-g,项目名称:core,代码行数:14,代码来源:deleteorphanedtagsjob.php
示例5: 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
示例6: afterException
/**
* Log error message and return a response which can be displayed to the user
*
* @param \OCP\AppFramework\Controller $controller
* @param string $methodName
* @param \Exception $exception
* @return JSONResponse
*/
public function afterException($controller, $methodName, \Exception $exception)
{
$this->logger->error($exception->getMessage(), ['app' => $this->appName]);
if ($exception instanceof HintException) {
$message = $exception->getHint();
} else {
$message = $exception->getMessage();
}
return new JSONResponse(['message' => $message], Http::STATUS_BAD_REQUEST);
}
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:18,代码来源:AddServerMiddleware.php
示例7: 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
示例8: isReady
/**
* check if new encryption is ready
*
* @return boolean
*/
public function isReady()
{
// check if we are still in transit between the old and the new encryption
$oldEncryption = $this->config->getAppValue('files_encryption', 'installed_version');
if (!empty($oldEncryption)) {
$warning = 'Installation is in transit between the old Encryption (ownCloud <= 8.0)
and the new encryption. Please enable the "Default encryption module"
and run \'occ encryption:migrate\'';
$this->logger->warning($warning);
return false;
}
return true;
}
开发者ID:brunomilet,项目名称:owncloud-core,代码行数:18,代码来源:manager.php
示例9: impersonate
/**
* become another user
* @param string $userid
* @UseSession
* @return JSONResponse
*/
public function impersonate($userid)
{
$oldUserId = $this->userSession->getUser()->getUID();
$this->logger->warning("User {$oldUserId} trying to impersonate user {$userid}", ['app' => 'impersonate']);
$user = $this->userManager->get($userid);
if ($user === null) {
return new JSONResponse("No user found for {$userid}", Http::STATUS_NOT_FOUND);
} else {
$this->logger->warning("changing to user {$userid}", ['app' => 'impersonate']);
$this->userSession->setUser($user);
}
return new JSONResponse();
}
开发者ID:AARNet,项目名称:impersonate,代码行数:19,代码来源:settingscontroller.php
示例10: createCollectionFromData
/**
* @param array $data
* @param integer $format
* @return SubscriptionCollection
*/
public function createCollectionFromData($data, $format)
{
$collection = new SubscriptionCollection();
foreach ($data as $item) {
try {
$entity = $this->createEntity($item, $format);
$collection->add($entity);
} catch (CorruptDataException $ex) {
$this->logger->info($ex->getMessage());
continue;
}
}
return $collection;
}
开发者ID:amin-hedayati,项目名称:calendar-rework,代码行数:19,代码来源:subscriptionfactory.php
示例11: schedule
/**
* Event handler for the 'schedule' event.
*
* @param ITip\Message $iTipMessage
* @return void
*/
function schedule(ITip\Message $iTipMessage)
{
// Not sending any emails if the system considers the update
// insignificant.
if (!$iTipMessage->significantChange) {
if (!$iTipMessage->scheduleStatus) {
$iTipMessage->scheduleStatus = '1.0;We got the message, but it\'s not significant enough to warrant an email';
}
return;
}
$summary = $iTipMessage->message->VEVENT->SUMMARY;
if (parse_url($iTipMessage->sender, PHP_URL_SCHEME) !== 'mailto') {
return;
}
if (parse_url($iTipMessage->recipient, PHP_URL_SCHEME) !== 'mailto') {
return;
}
$sender = substr($iTipMessage->sender, 7);
$recipient = substr($iTipMessage->recipient, 7);
$senderName = $iTipMessage->senderName ? $iTipMessage->senderName : null;
$recipientName = $iTipMessage->recipientName ? $iTipMessage->recipientName : null;
$subject = 'SabreDAV iTIP message';
switch (strtoupper($iTipMessage->method)) {
case 'REPLY':
$subject = 'Re: ' . $summary;
break;
case 'REQUEST':
$subject = $summary;
break;
case 'CANCEL':
$subject = 'Cancelled: ' . $summary;
break;
}
$contentType = 'text/calendar; charset=UTF-8; method=' . $iTipMessage->method;
$message = $this->mailer->createMessage();
$message->setReplyTo([$sender => $senderName])->setTo([$recipient => $recipientName])->setSubject($subject)->setBody($iTipMessage->message->serialize(), $contentType);
try {
$failed = $this->mailer->send($message);
if ($failed) {
$this->logger->error('Unable to deliver message to {failed}', ['app' => 'dav', 'failed' => implode(', ', $failed)]);
$iTipMessage->scheduleStatus = '5.0; EMail delivery failed';
}
$iTipMessage->scheduleStatus = '1.1; Scheduling message is sent via iMip';
} catch (\Exception $ex) {
$this->logger->logException($ex, ['app' => 'dav']);
$iTipMessage->scheduleStatus = '5.0; EMail delivery failed';
}
}
开发者ID:mnefedov,项目名称:core,代码行数:54,代码来源:imipplugin.php
示例12: 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
示例13: getApplicationDownload
/**
* Get the download url for an application from the OCS server
* @param string $id
* @param array $targetVersion The target ownCloud version
* @return array|null an array of application data or null
*/
public function getApplicationDownload($id, array $targetVersion)
{
if (!$this->isAppStoreEnabled()) {
return null;
}
$url = $this->getAppStoreUrl() . '/content/download/' . urlencode($id) . '/1';
$client = $this->httpClientService->newClient();
try {
$response = $client->get($url, ['timeout' => 5, 'query' => ['version' => implode('x', $targetVersion)]]);
} catch (\Exception $e) {
$this->logger->error(sprintf('Could not get application download URL: %s', $e->getMessage()), ['app' => 'core']);
return null;
}
$data = $this->loadData($response->getBody(), 'application download URL');
if ($data === null) {
return null;
}
$tmp = $data->data->content;
$app = [];
if (isset($tmp->downloadlink)) {
$app['downloadlink'] = (string) $tmp->downloadlink;
} else {
$app['downloadlink'] = '';
}
return $app;
}
开发者ID:kenwi,项目名称:core,代码行数:32,代码来源:ocsclient.php
示例14: draft
/**
* @NoAdminRequired
*
* @param int $accountId
* @param string $subject
* @param string $body
* @param string $to
* @param string $cc
* @param string $bcc
* @param int $uid
* @param string $messageId
* @return JSONResponse
*/
public function draft($accountId, $subject, $body, $to, $cc, $bcc, $uid, $messageId)
{
if (is_null($uid)) {
$this->logger->info("Saving a new draft in account <{$accountId}>");
} else {
$this->logger->info("Updating draft <{$uid}> in account <{$accountId}>");
}
$account = $this->accountService->find($this->currentUserId, $accountId);
if ($account instanceof UnifiedAccount) {
list($account) = $account->resolve($messageId);
}
if (!$account instanceof Account) {
return new JSONResponse(array('message' => 'Invalid account'), Http::STATUS_BAD_REQUEST);
}
$message = $account->newMessage();
$message->setTo(Message::parseAddressList($to));
$message->setSubject($subject ?: '');
$message->setFrom($account->getEMailAddress());
$message->setCC(Message::parseAddressList($cc));
$message->setBcc(Message::parseAddressList($bcc));
$message->setContent($body);
// create transport and save message
try {
$newUID = $account->saveDraft($message, $uid);
} catch (\Horde_Exception $ex) {
$this->logger->error('Saving draft failed: ' . $ex->getMessage());
return new JSONResponse(['message' => $ex->getMessage()], Http::STATUS_INTERNAL_SERVER_ERROR);
}
return new JSONResponse(['uid' => $newUID]);
}
开发者ID:WPSlicers,项目名称:mail,代码行数:43,代码来源:accountscontroller.php
示例15: testAddUserAsSubAdminExistingGroups
public function testAddUserAsSubAdminExistingGroups()
{
$_POST['userid'] = 'NewUser';
$_POST['password'] = 'PasswordOfTheNewUser';
$_POST['groups'] = ['ExistingGroup1', 'ExistingGroup2'];
$this->userManager->expects($this->once())->method('userExists')->with('NewUser')->willReturn(false);
$loggedInUser = $this->getMock('\\OCP\\IUser');
$loggedInUser->expects($this->once())->method('getUID')->will($this->returnValue('subAdminUser'));
$this->userSession->expects($this->once())->method('getUser')->will($this->returnValue($loggedInUser));
$this->groupManager->expects($this->once())->method('isAdmin')->with('subAdminUser')->willReturn(false);
$this->groupManager->expects($this->exactly(2))->method('groupExists')->withConsecutive(['ExistingGroup1'], ['ExistingGroup2'])->willReturn(true);
$user = $this->getMock('\\OCP\\IUser');
$this->userManager->expects($this->once())->method('createUser')->with('NewUser', 'PasswordOfTheNewUser')->willReturn($user);
$existingGroup1 = $this->getMock('\\OCP\\IGroup');
$existingGroup2 = $this->getMock('\\OCP\\IGroup');
$existingGroup1->expects($this->once())->method('addUser')->with($user);
$existingGroup2->expects($this->once())->method('addUser')->with($user);
$this->groupManager->expects($this->exactly(4))->method('get')->withConsecutive(['ExistingGroup1'], ['ExistingGroup2'], ['ExistingGroup1'], ['ExistingGroup2'])->will($this->returnValueMap([['ExistingGroup1', $existingGroup1], ['ExistingGroup2', $existingGroup2]]));
$this->logger->expects($this->exactly(3))->method('info')->withConsecutive(['Successful addUser call with userid: NewUser', ['app' => 'ocs_api']], ['Added userid NewUser to group ExistingGroup1', ['app' => 'ocs_api']], ['Added userid NewUser to group ExistingGroup2', ['app' => 'ocs_api']]);
$subAdminManager = $this->getMockBuilder('\\OC\\Subadmin')->disableOriginalConstructor()->getMock();
$this->groupManager->expects($this->once())->method('getSubAdmin')->willReturn($subAdminManager);
$subAdminManager->expects($this->once())->method('isSubAdmin')->with($loggedInUser)->willReturn(true);
$subAdminManager->expects($this->exactly(2))->method('isSubAdminOfGroup')->withConsecutive([$loggedInUser, $existingGroup1], [$loggedInUser, $existingGroup2])->wilLReturn(true);
$expected = new \OC_OCS_Result(null, 100);
$this->assertEquals($expected, $this->api->addUser());
}
开发者ID:DaubaKao,项目名称:owncloud-core,代码行数:26,代码来源:userstest.php
示例16: __construct
/**
* @param ICalendar $calendar
*/
public function __construct(ICalendar $calendar)
{
$this->calendar = $calendar;
$backend = $this->calendar->getBackend();
if (!$backend instanceof IBackend) {
$identifier = implode('::', [$this->calendar->getUserId(), '?', $this->calendar->getPrivateUri()]);
$this->logger->error('Backend of calendar \'' . $identifier . '\' not found');
} else {
$this->cache = $backend->getObjectCache($calendar);
try {
$this->objectAPI = $backend->getObjectAPI($calendar);
} catch (BackendUtils\Exception $ex) {
//TODO
}
}
}
开发者ID:amin-hedayati,项目名称:calendar-rework,代码行数:19,代码来源:scanner.php
示例17: 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
示例18: 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
示例19: cleanCommentMarkers
/**
* Deleting orphaned comment read markers
*
* @return int Number of deleted entries
*/
protected function cleanCommentMarkers()
{
$qb = $this->connection->getQueryBuilder();
$deletedEntries = $this->cleanUp('comments_read_markers', $qb->expr()->castColumn('object_id', IQueryBuilder::PARAM_INT), 'object_type');
$this->logger->debug("{$deletedEntries} orphaned comment read marks deleted", ['app' => 'DeleteOrphanedItems']);
return $deletedEntries;
}
开发者ID:farukuzun,项目名称:core-1,代码行数:12,代码来源:deleteorphaneditems.php
示例20: renameFileKeys
/**
* rename file keys
*
* @param string $user
* @param string $path
* @param bool $trash
*/
private function renameFileKeys($user, $path, $trash = false)
{
if ($this->view->is_dir($user . '/' . $path) === false) {
$this->logger->info('Skip dir /' . $user . '/' . $path . ': does not exist');
return;
}
$dh = $this->view->opendir($user . '/' . $path);
if (is_resource($dh)) {
while (($file = readdir($dh)) !== false) {
if (!\OC\Files\Filesystem::isIgnoredDir($file)) {
if ($this->view->is_dir($user . '/' . $path . '/' . $file)) {
$this->renameFileKeys($user, $path . '/' . $file, $trash);
} else {
$target = $this->getTargetDir($user, $path, $file, $trash);
if ($target) {
$this->createPathForKeys(dirname($target));
$this->view->rename($user . '/' . $path . '/' . $file, $target);
} else {
$this->logger->warning('did not move key "' . $file . '" could not find the corresponding file in /data/' . $user . '/files.' . 'Most likely the key was already moved in a previous migration run and is already on the right place.');
}
}
}
}
closedir($dh);
}
}
开发者ID:jzee,项目名称:core,代码行数:33,代码来源:migration.php
注:本文中的OCP\ILogger类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论