diff options
author | Anna Larch <anna@nextcloud.com> | 2022-07-04 15:43:04 +0200 |
---|---|---|
committer | Vincent Petry (Rebase PR Action) <PVince81@users.noreply.github.com> | 2022-07-27 15:00:38 +0000 |
commit | 2988efeb7fb83aa6a843647c5e2f40fcc61984d1 (patch) | |
tree | e48ec89f7fc1f9dfcb875ceb0cd7b60dfe648ca3 /apps/federation/lib | |
parent | d24823bda5c2fff264fb7d27f1cd2a8383515bcc (diff) | |
download | nextcloud-server-2988efeb7fb83aa6a843647c5e2f40fcc61984d1.tar.gz nextcloud-server-2988efeb7fb83aa6a843647c5e2f40fcc61984d1.zip |
Add logging to federation
Signed-off-by: Anna Larch <anna@nextcloud.com>
Diffstat (limited to 'apps/federation/lib')
-rw-r--r-- | apps/federation/lib/SyncFederationAddressBooks.php | 13 | ||||
-rw-r--r-- | apps/federation/lib/SyncJob.php | 2 |
2 files changed, 13 insertions, 2 deletions
diff --git a/apps/federation/lib/SyncFederationAddressBooks.php b/apps/federation/lib/SyncFederationAddressBooks.php index c17cb7618bf..401fd19bd75 100644 --- a/apps/federation/lib/SyncFederationAddressBooks.php +++ b/apps/federation/lib/SyncFederationAddressBooks.php @@ -29,19 +29,23 @@ use OC\OCS\DiscoveryService; use OCA\DAV\CardDAV\SyncService; use OCP\AppFramework\Http; use OCP\OCS\IDiscoveryService; +use Psr\Log\LoggerInterface; class SyncFederationAddressBooks { protected DbHandler $dbHandler; private SyncService $syncService; private DiscoveryService $ocsDiscoveryService; + private LoggerInterface $logger; public function __construct(DbHandler $dbHandler, SyncService $syncService, - IDiscoveryService $ocsDiscoveryService + IDiscoveryService $ocsDiscoveryService, + LoggerInterface $logger ) { $this->syncService = $syncService; $this->dbHandler = $dbHandler; $this->ocsDiscoveryService = $ocsDiscoveryService; + $this->logger = $logger; } /** @@ -60,6 +64,7 @@ class SyncFederationAddressBooks { $addressBookUrl = isset($endPoints['system-address-book']) ? trim($endPoints['system-address-book'], '/') : 'remote.php/dav/addressbooks/system/system/system'; if (is_null($sharedSecret)) { + $this->logger->debug("Shared secret for $url is null"); continue; } $targetBookId = $trustedServer['url_hash']; @@ -71,10 +76,16 @@ class SyncFederationAddressBooks { $newToken = $this->syncService->syncRemoteAddressBook($url, $cardDavUser, $addressBookUrl, $sharedSecret, $syncToken, $targetBookId, $targetPrincipal, $targetBookProperties); if ($newToken !== $syncToken) { $this->dbHandler->setServerStatus($url, TrustedServers::STATUS_OK, $newToken); + } else { + $this->logger->debug("Sync Token for $url unchanged from previous sync"); } } catch (\Exception $ex) { if ($ex->getCode() === Http::STATUS_UNAUTHORIZED) { $this->dbHandler->setServerStatus($url, TrustedServers::STATUS_ACCESS_REVOKED); + $this->logger->error("Server sync for $url failed because of revoked access."); + } else { + $this->dbHandler->setServerStatus($url, TrustedServers::STATUS_FAILURE); + $this->logger->error("Server sync for $url failed."); } $callback($url, $ex); } diff --git a/apps/federation/lib/SyncJob.php b/apps/federation/lib/SyncJob.php index 2498f309498..82063311f10 100644 --- a/apps/federation/lib/SyncJob.php +++ b/apps/federation/lib/SyncJob.php @@ -44,7 +44,7 @@ class SyncJob extends TimedJob { protected function run($argument) { $this->syncService->syncThemAll(function ($url, $ex) { if ($ex instanceof \Exception) { - $this->logger->info("Error while syncing $url.", [ + $this->logger->error("Error while syncing $url.", [ 'app' => 'fed-sync', 'exception' => $ex, ]); |