From 7ea99d5d449ba0cd0ac5de4c3028d77ed167d8a4 Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Fri, 3 Sep 2021 14:13:49 +0200 Subject: [PATCH] Debug log what happens during reminders processing Signed-off-by: Christoph Wurst --- .../lib/CalDAV/Reminder/ReminderService.php | 41 +++++++++++++------ 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/apps/dav/lib/CalDAV/Reminder/ReminderService.php b/apps/dav/lib/CalDAV/Reminder/ReminderService.php index b33bc8a175a72..2a06546905285 100644 --- a/apps/dav/lib/CalDAV/Reminder/ReminderService.php +++ b/apps/dav/lib/CalDAV/Reminder/ReminderService.php @@ -38,6 +38,7 @@ use OCP\IGroupManager; use OCP\IUser; use OCP\IUserManager; +use Psr\Log\LoggerInterface; use Sabre\VObject; use Sabre\VObject\Component\VAlarm; use Sabre\VObject\Component\VEvent; @@ -46,6 +47,7 @@ use Sabre\VObject\Recur\EventIterator; use Sabre\VObject\Recur\MaxInstancesExceededException; use Sabre\VObject\Recur\NoInstancesException; +use function count; use function strcasecmp; class ReminderService { @@ -71,6 +73,9 @@ class ReminderService { /** @var IConfig */ private $config; + /** @var LoggerInterface */ + private $logger; + public const REMINDER_TYPE_EMAIL = 'EMAIL'; public const REMINDER_TYPE_DISPLAY = 'DISPLAY'; public const REMINDER_TYPE_AUDIO = 'AUDIO'; @@ -86,24 +91,14 @@ class ReminderService { self::REMINDER_TYPE_AUDIO ]; - /** - * ReminderService constructor. - * - * @param Backend $backend - * @param NotificationProviderManager $notificationProviderManager - * @param IUserManager $userManager - * @param IGroupManager $groupManager - * @param CalDavBackend $caldavBackend - * @param ITimeFactory $timeFactory - * @param IConfig $config - */ public function __construct(Backend $backend, NotificationProviderManager $notificationProviderManager, IUserManager $userManager, IGroupManager $groupManager, CalDavBackend $caldavBackend, ITimeFactory $timeFactory, - IConfig $config) { + IConfig $config, + LoggerInterface $logger) { $this->backend = $backend; $this->notificationProviderManager = $notificationProviderManager; $this->userManager = $userManager; @@ -111,6 +106,7 @@ public function __construct(Backend $backend, $this->caldavBackend = $caldavBackend; $this->timeFactory = $timeFactory; $this->config = $config; + $this->logger = $logger; } /** @@ -119,8 +115,11 @@ public function __construct(Backend $backend, * @throws NotificationProvider\ProviderNotAvailableException * @throws NotificationTypeDoesNotExistException */ - public function processReminders():void { + public function processReminders() :void { $reminders = $this->backend->getRemindersToProcess(); + $this->logger->debug('{numReminders} reminders to process', [ + 'numReminders' => count($reminders), + ]); foreach ($reminders as $reminder) { $calendarData = is_resource($reminder['calendardata']) @@ -133,22 +132,34 @@ public function processReminders():void { $vcalendar = $this->parseCalendarData($calendarData); if (!$vcalendar) { + $this->logger->debug('Reminder {id} does not belong to a valid calendar', [ + 'id' => $reminder['id'], + ]); $this->backend->removeReminder($reminder['id']); continue; } $vevent = $this->getVEventByRecurrenceId($vcalendar, $reminder['recurrence_id'], $reminder['is_recurrence_exception']); if (!$vevent) { + $this->logger->debug('Reminder {id} does not belong to a valid event', [ + 'id' => $reminder['id'], + ]); $this->backend->removeReminder($reminder['id']); continue; } if ($this->wasEventCancelled($vevent)) { + $this->logger->debug('Reminder {id} belongs to a cancelled event', [ + 'id' => $reminder['id'], + ]); $this->deleteOrProcessNext($reminder, $vevent); continue; } if (!$this->notificationProviderManager->hasProvider($reminder['type'])) { + $this->logger->debug('Reminder {id} does not belong to a valid notification provider', [ + 'id' => $reminder['id'], + ]); $this->deleteOrProcessNext($reminder, $vevent); continue; } @@ -164,6 +175,10 @@ public function processReminders():void { $users[] = $user; } + $this->logger->debug('Reminder {id} will be sent to {numUsers} users', [ + 'id' => $reminder['id'], + 'numUsers' => count($users), + ]); $notificationProvider = $this->notificationProviderManager->getProvider($reminder['type']); $notificationProvider->send($vevent, $reminder['displayname'], $users);