diff options
author | Côme Chilliet <come.chilliet@nextcloud.com> | 2022-03-31 16:34:57 +0300 |
---|---|---|
committer | Côme Chilliet <come.chilliet@nextcloud.com> | 2022-05-02 11:52:43 +0300 |
commit | e2531f8503dea904dd1cb389ca017ce7bda5ccfc (patch) | |
tree | 683918ba234959dd76e771aaae2af434b21d09fe /apps/dav/lib/CalDAV | |
parent | 49b650c4a46c76121d74c6c37c0dbfa0d8f53dbe (diff) |
Migrate dav application from ILogger to LoggerInterface
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'apps/dav/lib/CalDAV')
10 files changed, 42 insertions, 122 deletions
diff --git a/apps/dav/lib/CalDAV/CalDavBackend.php b/apps/dav/lib/CalDAV/CalDavBackend.php index f0d332adab5..3253d41a5cd 100644 --- a/apps/dav/lib/CalDAV/CalDavBackend.php +++ b/apps/dav/lib/CalDAV/CalDavBackend.php @@ -69,10 +69,10 @@ use OCP\EventDispatcher\IEventDispatcher; use OCP\IConfig; use OCP\IDBConnection; use OCP\IGroupManager; -use OCP\ILogger; use OCP\IUser; use OCP\IUserManager; use OCP\Security\ISecureRandom; +use Psr\Log\LoggerInterface; use RuntimeException; use Sabre\CalDAV\Backend\AbstractBackend; use Sabre\CalDAV\Backend\SchedulingSupport; @@ -220,8 +220,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription /** @var ISecureRandom */ private $random; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; /** @var IEventDispatcher */ private $dispatcher; @@ -240,23 +239,13 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription /** * CalDavBackend constructor. - * - * @param IDBConnection $db - * @param Principal $principalBackend - * @param IUserManager $userManager - * @param IGroupManager $groupManager - * @param ISecureRandom $random - * @param ILogger $logger - * @param IEventDispatcher $dispatcher - * @param EventDispatcherInterface $legacyDispatcher - * @param bool $legacyEndpoint */ public function __construct(IDBConnection $db, Principal $principalBackend, IUserManager $userManager, IGroupManager $groupManager, ISecureRandom $random, - ILogger $logger, + LoggerInterface $logger, IEventDispatcher $dispatcher, EventDispatcherInterface $legacyDispatcher, IConfig $config, @@ -1715,15 +1704,15 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription try { $matches = $this->validateFilterForObject($row, $filters); } catch (ParseException $ex) { - $this->logger->logException($ex, [ + $this->logger->error('Caught parsing exception for calendar data. This usually indicates invalid calendar data. calendar-id:'.$calendarId.' uri:'.$row['uri'], [ 'app' => 'dav', - 'message' => 'Caught parsing exception for calendar data. This usually indicates invalid calendar data. calendar-id:'.$calendarId.' uri:'.$row['uri'] + 'exception' => $ex, ]); continue; } catch (InvalidDataException $ex) { - $this->logger->logException($ex, [ + $this->logger->error('Caught invalid data exception for calendar data. This usually indicates invalid calendar data. calendar-id:'.$calendarId.' uri:'.$row['uri'], [ 'app' => 'dav', - 'message' => 'Caught invalid data exception for calendar data. This usually indicates invalid calendar data. calendar-id:'.$calendarId.' uri:'.$row['uri'] + 'exception' => $ex, ]); continue; } diff --git a/apps/dav/lib/CalDAV/ICSExportPlugin/ICSExportPlugin.php b/apps/dav/lib/CalDAV/ICSExportPlugin/ICSExportPlugin.php index ae568720c55..0c76e4f5e10 100644 --- a/apps/dav/lib/CalDAV/ICSExportPlugin/ICSExportPlugin.php +++ b/apps/dav/lib/CalDAV/ICSExportPlugin/ICSExportPlugin.php @@ -23,7 +23,7 @@ namespace OCA\DAV\CalDAV\ICSExportPlugin; use OCP\IConfig; -use OCP\ILogger; +use Psr\Log\LoggerInterface; use Sabre\HTTP\ResponseInterface; use Sabre\VObject\DateTimeParser; use Sabre\VObject\InvalidDataException; @@ -39,18 +39,15 @@ class ICSExportPlugin extends \Sabre\CalDAV\ICSExportPlugin { /** @var IConfig */ private $config; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; /** @var string */ private const DEFAULT_REFRESH_INTERVAL = 'PT4H'; /** * ICSExportPlugin constructor. - * - * @param IConfig $config */ - public function __construct(IConfig $config, ILogger $logger) { + public function __construct(IConfig $config, LoggerInterface $logger) { $this->config = $config; $this->logger = $logger; } diff --git a/apps/dav/lib/CalDAV/Reminder/NotificationProvider/AbstractProvider.php b/apps/dav/lib/CalDAV/Reminder/NotificationProvider/AbstractProvider.php index 044e5fac4e2..49cf36f98ac 100644 --- a/apps/dav/lib/CalDAV/Reminder/NotificationProvider/AbstractProvider.php +++ b/apps/dav/lib/CalDAV/Reminder/NotificationProvider/AbstractProvider.php @@ -32,10 +32,10 @@ namespace OCA\DAV\CalDAV\Reminder\NotificationProvider; use OCA\DAV\CalDAV\Reminder\INotificationProvider; use OCP\IConfig; use OCP\IL10N; -use OCP\ILogger; use OCP\IURLGenerator; use OCP\IUser; use OCP\L10N\IFactory as L10NFactory; +use Psr\Log\LoggerInterface; use Sabre\VObject\Component\VEvent; use Sabre\VObject\DateTimeParser; use Sabre\VObject\Property; @@ -50,8 +50,7 @@ abstract class AbstractProvider implements INotificationProvider { /** @var string */ public const NOTIFICATION_TYPE = ''; - /** @var ILogger */ - protected $logger; + protected LoggerInterface $logger; /** @var L10NFactory */ protected $l10nFactory; @@ -68,13 +67,7 @@ abstract class AbstractProvider implements INotificationProvider { /** @var IConfig */ protected $config; - /** - * @param ILogger $logger - * @param L10NFactory $l10nFactory - * @param IConfig $config - * @param IUrlGenerator $urlGenerator - */ - public function __construct(ILogger $logger, + public function __construct(LoggerInterface $logger, L10NFactory $l10nFactory, IURLGenerator $urlGenerator, IConfig $config) { diff --git a/apps/dav/lib/CalDAV/Reminder/NotificationProvider/EmailProvider.php b/apps/dav/lib/CalDAV/Reminder/NotificationProvider/EmailProvider.php index 456b9f8b42d..7e0020b5f55 100644 --- a/apps/dav/lib/CalDAV/Reminder/NotificationProvider/EmailProvider.php +++ b/apps/dav/lib/CalDAV/Reminder/NotificationProvider/EmailProvider.php @@ -34,11 +34,11 @@ namespace OCA\DAV\CalDAV\Reminder\NotificationProvider; use DateTime; use OCP\IConfig; use OCP\IL10N; -use OCP\ILogger; use OCP\IURLGenerator; use OCP\L10N\IFactory as L10NFactory; use OCP\Mail\IEMailTemplate; use OCP\Mail\IMailer; +use Psr\Log\LoggerInterface; use Sabre\VObject; use Sabre\VObject\Component\VEvent; use Sabre\VObject\Parameter; @@ -57,16 +57,9 @@ class EmailProvider extends AbstractProvider { /** @var IMailer */ private $mailer; - /** - * @param IConfig $config - * @param IMailer $mailer - * @param ILogger $logger - * @param L10NFactory $l10nFactory - * @param IUrlGenerator $urlGenerator - */ public function __construct(IConfig $config, IMailer $mailer, - ILogger $logger, + LoggerInterface $logger, L10NFactory $l10nFactory, IURLGenerator $urlGenerator) { parent::__construct($logger, $l10nFactory, $urlGenerator, $config); @@ -133,7 +126,7 @@ class EmailProvider extends AbstractProvider { $this->logger->error('Unable to deliver message to {failed}', ['app' => 'dav', 'failed' => implode(', ', $failed)]); } } catch (\Exception $ex) { - $this->logger->logException($ex, ['app' => 'dav']); + $this->logger->error($ex->getMessage(), ['app' => 'dav', 'exception' => $ex]); } } } diff --git a/apps/dav/lib/CalDAV/Reminder/NotificationProvider/PushProvider.php b/apps/dav/lib/CalDAV/Reminder/NotificationProvider/PushProvider.php index fb123960df8..298297fdc38 100644 --- a/apps/dav/lib/CalDAV/Reminder/NotificationProvider/PushProvider.php +++ b/apps/dav/lib/CalDAV/Reminder/NotificationProvider/PushProvider.php @@ -32,12 +32,12 @@ namespace OCA\DAV\CalDAV\Reminder\NotificationProvider; use OCA\DAV\AppInfo\Application; use OCP\AppFramework\Utility\ITimeFactory; use OCP\IConfig; -use OCP\ILogger; use OCP\IURLGenerator; use OCP\IUser; use OCP\L10N\IFactory as L10NFactory; use OCP\Notification\IManager; use OCP\Notification\INotification; +use Psr\Log\LoggerInterface; use Sabre\VObject\Component\VEvent; use Sabre\VObject\Property; @@ -57,17 +57,9 @@ class PushProvider extends AbstractProvider { /** @var ITimeFactory */ private $timeFactory; - /** - * @param IConfig $config - * @param IManager $manager - * @param ILogger $logger - * @param L10NFactory $l10nFactory - * @param IUrlGenerator $urlGenerator - * @param ITimeFactory $timeFactory - */ public function __construct(IConfig $config, IManager $manager, - ILogger $logger, + LoggerInterface $logger, L10NFactory $l10nFactory, IURLGenerator $urlGenerator, ITimeFactory $timeFactory) { diff --git a/apps/dav/lib/CalDAV/ResourceBooking/AbstractPrincipalBackend.php b/apps/dav/lib/CalDAV/ResourceBooking/AbstractPrincipalBackend.php index aebb5a24f0e..6fd69b7e3df 100644 --- a/apps/dav/lib/CalDAV/ResourceBooking/AbstractPrincipalBackend.php +++ b/apps/dav/lib/CalDAV/ResourceBooking/AbstractPrincipalBackend.php @@ -33,8 +33,8 @@ use OCP\DB\Exception; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IDBConnection; use OCP\IGroupManager; -use OCP\ILogger; use OCP\IUserSession; +use Psr\Log\LoggerInterface; use Sabre\DAV\PropPatch; use Sabre\DAVACL\PrincipalBackend\BackendInterface; use function array_intersect; @@ -54,8 +54,7 @@ abstract class AbstractPrincipalBackend implements BackendInterface { /** @var IGroupManager */ private $groupManager; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; /** @var ProxyMapper */ private $proxyMapper; @@ -75,19 +74,10 @@ abstract class AbstractPrincipalBackend implements BackendInterface { /** @var string */ private $cuType; - /** - * @param IDBConnection $dbConnection - * @param IUserSession $userSession - * @param IGroupManager $groupManager - * @param ILogger $logger - * @param string $principalPrefix - * @param string $dbPrefix - * @param string $cuType - */ public function __construct(IDBConnection $dbConnection, IUserSession $userSession, IGroupManager $groupManager, - ILogger $logger, + LoggerInterface $logger, ProxyMapper $proxyMapper, string $principalPrefix, string $dbPrefix, diff --git a/apps/dav/lib/CalDAV/ResourceBooking/ResourcePrincipalBackend.php b/apps/dav/lib/CalDAV/ResourceBooking/ResourcePrincipalBackend.php index 65203e24da5..20fdadbca0c 100644 --- a/apps/dav/lib/CalDAV/ResourceBooking/ResourcePrincipalBackend.php +++ b/apps/dav/lib/CalDAV/ResourceBooking/ResourcePrincipalBackend.php @@ -25,8 +25,8 @@ namespace OCA\DAV\CalDAV\ResourceBooking; use OCA\DAV\CalDAV\Proxy\ProxyMapper; use OCP\IDBConnection; use OCP\IGroupManager; -use OCP\ILogger; use OCP\IUserSession; +use Psr\Log\LoggerInterface; /** * Class ResourcePrincipalBackend @@ -37,17 +37,11 @@ class ResourcePrincipalBackend extends AbstractPrincipalBackend { /** * ResourcePrincipalBackend constructor. - * - * @param IDBConnection $dbConnection - * @param IUserSession $userSession - * @param IGroupManager $groupManager - * @param ILogger $logger - * @param ProxyMapper $proxyMapper */ public function __construct(IDBConnection $dbConnection, IUserSession $userSession, IGroupManager $groupManager, - ILogger $logger, + LoggerInterface $logger, ProxyMapper $proxyMapper) { parent::__construct($dbConnection, $userSession, $groupManager, $logger, $proxyMapper, 'principals/calendar-resources', 'resource', 'RESOURCE'); diff --git a/apps/dav/lib/CalDAV/ResourceBooking/RoomPrincipalBackend.php b/apps/dav/lib/CalDAV/ResourceBooking/RoomPrincipalBackend.php index ca78ebd4bc4..931635d632f 100644 --- a/apps/dav/lib/CalDAV/ResourceBooking/RoomPrincipalBackend.php +++ b/apps/dav/lib/CalDAV/ResourceBooking/RoomPrincipalBackend.php @@ -25,8 +25,8 @@ namespace OCA\DAV\CalDAV\ResourceBooking; use OCA\DAV\CalDAV\Proxy\ProxyMapper; use OCP\IDBConnection; use OCP\IGroupManager; -use OCP\ILogger; use OCP\IUserSession; +use Psr\Log\LoggerInterface; /** * Class RoomPrincipalBackend @@ -37,17 +37,11 @@ class RoomPrincipalBackend extends AbstractPrincipalBackend { /** * RoomPrincipalBackend constructor. - * - * @param IDBConnection $dbConnection - * @param IUserSession $userSession - * @param IGroupManager $groupManager - * @param ILogger $logger - * @param ProxyMapper $proxyMapper */ public function __construct(IDBConnection $dbConnection, IUserSession $userSession, IGroupManager $groupManager, - ILogger $logger, + LoggerInterface $logger, ProxyMapper $proxyMapper) { parent::__construct($dbConnection, $userSession, $groupManager, $logger, $proxyMapper, 'principals/calendar-rooms', 'room', 'ROOM'); diff --git a/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php b/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php index 8aacc33bb46..2c7b06a4396 100644 --- a/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php +++ b/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php @@ -39,7 +39,6 @@ use OCP\Defaults; use OCP\IConfig; use OCP\IDBConnection; use OCP\IL10N; -use OCP\ILogger; use OCP\IURLGenerator; use OCP\IUserManager; use OCP\L10N\IFactory as L10NFactory; @@ -47,6 +46,7 @@ use OCP\Mail\IEMailTemplate; use OCP\Mail\IMailer; use OCP\Security\ISecureRandom; use OCP\Util; +use Psr\Log\LoggerInterface; use Sabre\CalDAV\Schedule\IMipPlugin as SabreIMipPlugin; use Sabre\VObject\Component\VCalendar; use Sabre\VObject\Component\VEvent; @@ -81,8 +81,7 @@ class IMipPlugin extends SabreIMipPlugin { /** @var IMailer */ private $mailer; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; /** @var ITimeFactory */ private $timeFactory; @@ -112,19 +111,8 @@ class IMipPlugin extends SabreIMipPlugin { public const METHOD_CANCEL = 'cancel'; public const IMIP_INDENT = 15; // Enough for the length of all body bullet items, in all languages - /** - * @param IConfig $config - * @param IMailer $mailer - * @param ILogger $logger - * @param ITimeFactory $timeFactory - * @param L10NFactory $l10nFactory - * @param IUrlGenerator $urlGenerator - * @param Defaults $defaults - * @param ISecureRandom $random - * @param IDBConnection $db - * @param string $userId - */ - public function __construct(IConfig $config, IMailer $mailer, ILogger $logger, + public function __construct(IConfig $config, IMailer $mailer, + LoggerInterface $logger, ITimeFactory $timeFactory, L10NFactory $l10nFactory, IURLGenerator $urlGenerator, Defaults $defaults, ISecureRandom $random, IDBConnection $db, IUserManager $userManager, @@ -306,7 +294,7 @@ class IMipPlugin extends SabreIMipPlugin { $iTipMessage->scheduleStatus = '5.0; EMail delivery failed'; } } catch (\Exception $ex) { - $this->logger->logException($ex, ['app' => 'dav']); + $this->logger->error($ex->getMessage(), ['app' => 'dav', 'exception' => $ex]); $iTipMessage->scheduleStatus = '5.0; EMail delivery failed'; } } diff --git a/apps/dav/lib/CalDAV/WebcalCaching/RefreshWebcalService.php b/apps/dav/lib/CalDAV/WebcalCaching/RefreshWebcalService.php index 543d15e0179..49f66735345 100644 --- a/apps/dav/lib/CalDAV/WebcalCaching/RefreshWebcalService.php +++ b/apps/dav/lib/CalDAV/WebcalCaching/RefreshWebcalService.php @@ -37,9 +37,9 @@ use OCA\DAV\CalDAV\CalDavBackend; use OCP\Http\Client\IClientService; use OCP\Http\Client\LocalServerException; use OCP\IConfig; -use OCP\ILogger; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; +use Psr\Log\LoggerInterface; use Sabre\DAV\Exception\BadRequest; use Sabre\DAV\PropPatch; use Sabre\DAV\Xml\Property\Href; @@ -64,8 +64,7 @@ class RefreshWebcalService { /** @var IConfig */ private $config; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; public const REFRESH_RATE = '{http://apple.com/ns/ical/}refreshrate'; public const STRIP_ALARMS = '{http://calendarserver.org/ns/}subscribed-strip-alarms'; @@ -74,23 +73,17 @@ class RefreshWebcalService { /** * RefreshWebcalJob constructor. - * - * @param CalDavBackend $calDavBackend - * @param IClientService $clientService - * @param IConfig $config - * @param ILogger $logger */ - public function __construct(CalDavBackend $calDavBackend, IClientService $clientService, IConfig $config, ILogger $logger) { + public function __construct(CalDavBackend $calDavBackend, + IClientService $clientService, + IConfig $config, + LoggerInterface $logger) { $this->calDavBackend = $calDavBackend; $this->clientService = $clientService; $this->config = $config; $this->logger = $logger; } - /** - * @param string $principalUri - * @param string $uri - */ public function refreshSubscription(string $principalUri, string $uri) { $subscription = $this->getSubscription($principalUri, $uri); $mutations = []; @@ -143,7 +136,7 @@ class RefreshWebcalService { try { $this->calDavBackend->createCalendarObject($subscription['id'], $uri, $calendarData, CalDavBackend::CALENDAR_TYPE_SUBSCRIPTION); } catch (NoInstancesException | BadRequest $ex) { - $this->logger->logException($ex); + $this->logger->error($ex->getMessage(), ['exception' => $ex]); } } @@ -156,8 +149,7 @@ class RefreshWebcalService { } catch (ParseException $ex) { $subscriptionId = $subscription['id']; - $this->logger->logException($ex); - $this->logger->warning("Subscription $subscriptionId could not be refreshed due to a parsing error"); + $this->logger->error("Subscription $subscriptionId could not be refreshed due to a parsing error", ['exception' => $ex]); } } @@ -279,16 +271,14 @@ class RefreshWebcalService { return $vCalendar->serialize(); } } catch (LocalServerException $ex) { - $this->logger->logException($ex, [ - 'message' => "Subscription $subscriptionId was not refreshed because it violates local access rules", - 'level' => ILogger::WARN, + $this->logger->warning("Subscription $subscriptionId was not refreshed because it violates local access rules", [ + 'exception' => $ex, ]); return null; } catch (Exception $ex) { - $this->logger->logException($ex, [ - 'message' => "Subscription $subscriptionId could not be refreshed due to a network error", - 'level' => ILogger::WARN, + $this->logger->warning("Subscription $subscriptionId could not be refreshed due to a network error", [ + 'exception' => $ex, ]); return null; |