diff options
Diffstat (limited to 'apps/federatedfilesharing')
3 files changed, 34 insertions, 22 deletions
diff --git a/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php b/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php index 19f98b264e6..a54a3aa69a0 100644 --- a/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php +++ b/apps/federatedfilesharing/lib/Controller/MountPublicLinkController.php @@ -164,6 +164,10 @@ class MountPublicLinkController extends Controller { try { $this->federatedShareProvider->create($share); } catch (\Exception $e) { + \OC::$server->getLogger()->logException($e, [ + 'level' => \OCP\Util::WARN, + 'app' => 'federatedfilesharing', + ]); return new JSONResponse(['message' => $e->getMessage()], Http::STATUS_BAD_REQUEST); } @@ -286,18 +290,18 @@ class MountPublicLinkController extends Controller { $storage->checkStorageAvailability(); } catch (StorageInvalidException $e) { // note: checkStorageAvailability will already remove the invalid share - Util::writeLog( - 'federatedfilesharing', - 'Invalid remote storage: ' . get_class($e) . ': ' . $e->getMessage(), - Util::DEBUG - ); + \OC::$server->getLogger()->logException($e, [ + 'message' => 'Invalid remote storage.', + 'level' => \OCP\Util::DEBUG, + 'app' => 'federatedfilesharing' + ]); return new JSONResponse(['message' => $this->l->t('Could not authenticate to remote share, password might be wrong')], Http::STATUS_BAD_REQUEST); } catch (\Exception $e) { - Util::writeLog( - 'federatedfilesharing', - 'Invalid remote storage: ' . get_class($e) . ': ' . $e->getMessage(), - Util::DEBUG - ); + \OC::$server->getLogger()->logException($e, [ + 'message' => 'Invalid remote storage.', + 'level' => \OCP\Util::DEBUG, + 'app' => 'federatedfilesharing' + ]); $externalManager->removeShare($mount->getMountPoint()); return new JSONResponse(['message' => $this->l->t('Storage not valid')], Http::STATUS_BAD_REQUEST); } @@ -312,18 +316,18 @@ class MountPublicLinkController extends Controller { ] ); } catch (StorageInvalidException $e) { - Util::writeLog( - 'federatedfilesharing', - 'Invalid remote storage: ' . get_class($e) . ': ' . $e->getMessage(), - Util::DEBUG - ); + \OC::$server->getLogger()->logException($e, [ + 'message' => 'Invalid remote storage.', + 'level' => \OCP\Util::DEBUG, + 'app' => 'federatedfilesharing' + ]); return new JSONResponse(['message' => $this->l->t('Storage not valid')], Http::STATUS_BAD_REQUEST); } catch (\Exception $e) { - Util::writeLog( - 'federatedfilesharing', - 'Invalid remote storage: ' . get_class($e) . ': ' . $e->getMessage(), - Util::DEBUG - ); + \OC::$server->getLogger()->logException($e, [ + 'message' => 'Invalid remote storage.', + 'level' => \OCP\Util::DEBUG, + 'app' => 'federatedfilesharing' + ]); return new JSONResponse(['message' => $this->l->t('Couldn\'t add remote share')], Http::STATUS_BAD_REQUEST); } } else { diff --git a/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php b/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php index a74342f1182..bc81db50b28 100644 --- a/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php +++ b/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php @@ -209,7 +209,11 @@ class RequestHandlerController extends OCSController { return new Http\DataResponse(); } catch (\Exception $e) { - \OCP\Util::writeLog('files_sharing', 'server can not add remote share, ' . $e->getMessage(), \OCP\Util::ERROR); + \OC::$server->getLogger()->logException($e, [ + 'message' => 'Server can not add remote share.', + 'level' => \OCP\Util::ERROR, + 'app' => 'files_sharing' + ]); throw new OCSException('internal server error, was not able to add share from ' . $remote, 500); } } diff --git a/apps/federatedfilesharing/lib/FederatedShareProvider.php b/apps/federatedfilesharing/lib/FederatedShareProvider.php index 27606c5fdec..1025c3c4ae7 100644 --- a/apps/federatedfilesharing/lib/FederatedShareProvider.php +++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php @@ -264,7 +264,11 @@ class FederatedShareProvider implements IShareProvider { $failure = true; } } catch (\Exception $e) { - $this->logger->error('Failed to notify remote server of federated share, removing share (' . $e->getMessage() . ')'); + $this->logger->logException($e, [ + 'message' => 'Failed to notify remote server of federated share, removing share.', + 'level' => \OCP\Util::ERROR, + 'app' => 'federatedfilesharing', + ]); $failure = true; } |