refactor: Migrate away from deprecated ILogger interface to PSR-3

Mostly replace `ILogger` with `LoggerInterface` and some minor cleanup (constructor property promotion).
Some places used the deprecated `logException` this is easy to migrate by simply use the appropriate loglevel on the logger
and place the exception under the `exception` key in the context.
Also the manual checking of the configured log level is not needed, as this is already done by the logger.

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
This commit is contained in:
Ferdinand Thiessen
2024-08-19 13:48:49 +02:00
parent 3e1805b09b
commit beb563e74e
9 changed files with 75 additions and 142 deletions

View File

@@ -12,27 +12,17 @@ use OCA\Deck\Notification\NotificationHelper;
use OCP\AppFramework\Db\DoesNotExistException;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\Job;
use OCP\ILogger;
use Psr\Log\LoggerInterface;
class ScheduledNotifications extends Job {
/** @var CardMapper */
protected $cardMapper;
/** @var NotificationHelper */
protected $notificationHelper;
/** @var ILogger */
protected $logger;
public function __construct(
ITimeFactory $time,
CardMapper $cardMapper,
NotificationHelper $notificationHelper,
ILogger $logger
protected CardMapper $cardMapper,
protected NotificationHelper $notificationHelper,
protected LoggerInterface $logger
) {
parent::__construct($time);
$this->cardMapper = $cardMapper;
$this->notificationHelper = $notificationHelper;
$this->logger = $logger;
}
/**

View File

@@ -14,21 +14,19 @@ namespace OCA\Deck\Cron;
use OCA\Deck\Service\SessionService;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\TimedJob;
use OCP\ILogger;
use Psr\Log\LoggerInterface;
class SessionsCleanup extends TimedJob {
private $sessionService;
private $documentService;
private $logger;
private $imageService;
public function __construct(ITimeFactory $time,
SessionService $sessionService,
ILogger $logger) {
public function __construct(
ITimeFactory $time,
private SessionService $sessionService,
private LoggerInterface $logger,
) {
parent::__construct($time);
$this->sessionService = $sessionService;
$this->logger = $logger;
$this->setInterval(SessionService::SESSION_VALID_TIME);
}