diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-09-23 18:00:00 +0300 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-09-23 21:48:55 +0300 |
commit | 635e03fc71980d4b6f7b4aa2958af7a557c7f974 (patch) | |
tree | 53ba2e799afe223dbaca5e5aa1377294176626d5 /lib/BackgroundJob | |
parent | 57e02700a69edccddeaa1f169cb18335e8baf5db (diff) |
Add debug output to sync processes triggered via the CLI
Just like a CLI priority inbox model training gives all the details, we
want to have the same to diagnose slow/faulty account syncs. This
changes the console logger adapter for the PSR logger and adds it to the
sync process.
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'lib/BackgroundJob')
-rw-r--r-- | lib/BackgroundJob/SyncJob.php | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/BackgroundJob/SyncJob.php b/lib/BackgroundJob/SyncJob.php index aea334612..8d10c549f 100644 --- a/lib/BackgroundJob/SyncJob.php +++ b/lib/BackgroundJob/SyncJob.php @@ -33,7 +33,7 @@ use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Utility\ITimeFactory; use OCP\BackgroundJob\IJobList; use OCP\BackgroundJob\TimedJob; -use OCP\ILogger; +use Psr\Log\LoggerInterface; use Throwable; class SyncJob extends TimedJob { @@ -47,7 +47,7 @@ class SyncJob extends TimedJob { /** @var MailboxSync */ private $mailboxSync; - /** @var ILogger */ + /** @var LoggerInterface */ private $logger; /** @var IJobList */ @@ -57,7 +57,7 @@ class SyncJob extends TimedJob { AccountService $accountService, MailboxSync $mailboxSync, ImapToDbSynchronizer $syncService, - ILogger $logger, + LoggerInterface $logger, IJobList $jobList) { parent::__construct($time); @@ -88,15 +88,15 @@ class SyncJob extends TimedJob { } try { - $this->mailboxSync->sync($account, true); - $this->syncService->syncAccount($account); + $this->mailboxSync->sync($account, $this->logger,true); + $this->syncService->syncAccount($account, $this->logger); } catch (IncompleteSyncException $e) { - $this->logger->logException($e, [ - 'level' => ILogger::WARN, + $this->logger->warning($e->getMessage(), [ + 'exception' => $e, ]); } catch (Throwable $e) { - $this->logger->logException($e, [ - 'message' => 'Cron mail sync failed: ' . $e->getMessage(), + $this->logger->error('Cron mail sync failed: ' . $e->getMessage(), [ + 'exception' => $e, ]); } } |