Skip to content

Commit

Permalink
fix(psalm): drop TLogger completely
Browse files Browse the repository at this point in the history
Signed-off-by: Max <[email protected]>
  • Loading branch information
max-nextcloud committed Feb 17, 2025
1 parent 4f5c5ae commit c11c436
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 215 deletions.
8 changes: 5 additions & 3 deletions lib/Controller/LockController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
use OCA\FilesLock\Model\FileLock;
use OCA\FilesLock\Service\FileService;
use OCA\FilesLock\Service\LockService;
use OCA\FilesLock\Tools\Traits\TLogger;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCSController;
Expand All @@ -48,19 +47,21 @@
use OCP\IL10N;
use OCP\IRequest;
use OCP\IUserSession;
use Psr\Log\LoggerInterface;

/**
* Class LockController
*
* @package OCA\FilesLock\Controller
*/
class LockController extends OCSController {
use TLogger;

private int $ocsVersion;
private LoggerInterface $logger;

public function __construct(
IRequest $request,
LoggerInterface $logger,
private IUserSession $userSession,
private FileService $fileService,
private LockService $lockService,
Expand All @@ -82,6 +83,7 @@ public function __construct(
$this->registerResponder('xml', function ($data) {
return $this->buildOCSResponse('xml', $data);
});
$this->logger = $logger;
}


Expand Down Expand Up @@ -197,7 +199,7 @@ protected function fail(
);

if ($log) {
$this->log(2, $status . ' - ' . json_encode($data));
$this->logger->warning('[warning] ' . $status . ' - ' . json_encode($data));
}

return new DataResponse($data, $status);
Expand Down
17 changes: 6 additions & 11 deletions lib/Service/LockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
use OCA\FilesLock\Exceptions\LockNotFoundException;
use OCA\FilesLock\Exceptions\UnauthorizedUnlockException;
use OCA\FilesLock\Model\FileLock;
use OCA\FilesLock\Tools\Traits\TLogger;
use OCA\FilesLock\Tools\Traits\TStringTools;
use OCP\App\IAppManager;
use OCP\EventDispatcher\IEventDispatcher;
Expand All @@ -56,8 +55,6 @@ class LockService {


use TStringTools;
use TLogger;


private IUserManager $userManager;
private IL10N $l10n;
Expand Down Expand Up @@ -100,8 +97,6 @@ public function __construct(
$this->userSession = $userSession;
$this->request = $request;
$this->logger = $logger;

$this->setup('app', 'files_lock');
}

/**
Expand Down Expand Up @@ -179,7 +174,7 @@ public function lock(LockContext $lockScope): FileLock {
$known->setTimeout(
$known->getETA() !== FileLock::ETA_INFINITE ? $known->getTimeout() - $known->getETA() + $this->configService->getTimeoutSeconds() : 0
);
$this->notice('extending existing lock', false, ['fileLock' => $known]);
$this->logger->notice('extending existing lock', ['fileLock' => $known]);
$this->locksRequest->update($known);
$this->injectMetadata($known);
return $known;
Expand All @@ -191,7 +186,7 @@ public function lock(LockContext $lockScope): FileLock {
$lock = FileLock::fromLockScope($lockScope, $this->configService->getTimeoutSeconds());
$this->generateToken($lock);
$lock->setCreation(time());
$this->notice('locking file', false, ['fileLock' => $lock]);
$this->logger->notice('locking file', ['fileLock' => $lock]);
$this->injectMetadata($lock);
$this->locksRequest->save($lock);
$this->propagateEtag($lockScope);
Expand All @@ -215,7 +210,7 @@ public function getAppName(string $appId): ?string {
* @throws UnauthorizedUnlockException
*/
public function unlock(LockContext $lock, bool $force = false): FileLock {
$this->notice('unlocking file', false, ['fileLock' => $lock]);
$this->logger->notice('unlocking file', ['fileLock' => $lock]);

$known = $this->getLockFromFileId($lock->getNode()->getId());
if (!$force) {
Expand Down Expand Up @@ -306,8 +301,8 @@ public function unlockFile(int $fileId, string $userId, bool $force = false, int
public function getDeprecatedLocks(): array {
$timeout = (int)$this->configService->getAppValue(ConfigService::LOCK_TIMEOUT);
if ($timeout === 0) {
$this->notice(
'ConfigService::LOCK_TIMEOUT is not numerical, using default', true, ['current' => $timeout]
$this->logger->notice(
'ConfigService::LOCK_TIMEOUT is not numerical, using default', ['current' => $timeout, 'exception' => new \Exception()]
);
$timeout = (int)$this->configService->defaults[ConfigService::LOCK_TIMEOUT];
}
Expand Down Expand Up @@ -403,7 +398,7 @@ function (FileLock $lock) {
}, $locks
);

$this->notice('removing locks', false, ['ids' => $ids]);
$this->logger->notice('removing locks', ['ids' => $ids]);

$this->locksRequest->removeIds($ids);
}
Expand Down
201 changes: 0 additions & 201 deletions lib/Tools/Traits/TLogger.php

This file was deleted.

0 comments on commit c11c436

Please sign in to comment.