From 77825e69619dc524653d539a8ba0d8132130c9dc Mon Sep 17 00:00:00 2001 From: Samuel Date: Mon, 8 Feb 2021 10:11:00 +0100 Subject: [PATCH] fix(logger): set logger in constructor Signed-off-by: Samuel --- apps/federatedfilesharing/lib/Notifications.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/apps/federatedfilesharing/lib/Notifications.php b/apps/federatedfilesharing/lib/Notifications.php index 52aa83fad4..181a099495 100644 --- a/apps/federatedfilesharing/lib/Notifications.php +++ b/apps/federatedfilesharing/lib/Notifications.php @@ -35,6 +35,7 @@ use OCP\Federation\ICloudFederationFactory; use OCP\Federation\ICloudFederationProviderManager; use OCP\Http\Client\IClientService; use OCP\OCS\IDiscoveryService; +use OCP\ILogger; class Notifications { public const RESPONSE_FORMAT = 'json'; // default response format for ocs calls @@ -60,6 +61,9 @@ class Notifications { /** @var IEventDispatcher */ private $eventDispatcher; + /** @var ILogger */ + protected $logger; + public function __construct( AddressHandler $addressHandler, IClientService $httpClientService, @@ -73,6 +77,7 @@ class Notifications { $this->httpClientService = $httpClientService; $this->discoveryService = $discoveryService; $this->jobList = $jobList; + $this->logger = OC::$server->getLogger(); $this->federationProviderManager = $federationProviderManager; $this->cloudFederationFactory = $cloudFederationFactory; $this->eventDispatcher = $eventDispatcher; @@ -124,13 +129,13 @@ class Notifications { $this->eventDispatcher->dispatchTyped($event); return true; } else { - \OC::$server->getLogger()->info( + $this->logger->info( "failed sharing $name with $shareWith", ['app' => 'federatedfilesharing'] ); } } else { - \OC::$server->getLogger()->info( + $this->logger->info( "could not share $name, invalid contact $shareWith", ['app' => 'federatedfilesharing'] ); @@ -185,17 +190,17 @@ class Notifications { $status['ocs']['data']['remoteId'] ]; } elseif (!$validToken) { - \OC::$server->getLogger()->info( + $this->logger->info( "invalid or missing token requesting re-share for $filename to $remote", ['app' => 'federatedfilesharing'] ); } elseif (!$validRemoteId) { - \OC::$server->getLogger()->info( + $this->logger->info( "missing remote id requesting re-share for $filename to $remote", ['app' => 'federatedfilesharing'] ); } else { - \OC::$server->getLogger()->info( + $this->logger->info( "failed requesting re-share for $filename to $remote", ['app' => 'federatedfilesharing'] );