Skip to content

Commit 48dde0c

Browse files
committed
fix(psalm): drop TLogger completely
Signed-off-by: Max <[email protected]>
1 parent bdcdd3e commit 48dde0c

File tree

3 files changed

+11
-195
lines changed

3 files changed

+11
-195
lines changed

lib/Controller/LockController.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use OCA\FilesLock\Model\FileLock;
1717
use OCA\FilesLock\Service\FileService;
1818
use OCA\FilesLock\Service\LockService;
19-
use OCA\FilesLock\Tools\Traits\TLogger;
2019
use OCP\AppFramework\Http;
2120
use OCP\AppFramework\Http\DataResponse;
2221
use OCP\AppFramework\OCSController;
@@ -26,19 +25,21 @@
2625
use OCP\IL10N;
2726
use OCP\IRequest;
2827
use OCP\IUserSession;
28+
use Psr\Log\LoggerInterface;
2929

3030
/**
3131
* Class LockController
3232
*
3333
* @package OCA\FilesLock\Controller
3434
*/
3535
class LockController extends OCSController {
36-
use TLogger;
3736

3837
private int $ocsVersion;
38+
private LoggerInterface $logger;
3939

4040
public function __construct(
4141
IRequest $request,
42+
LoggerInterface $logger,
4243
private IUserSession $userSession,
4344
private FileService $fileService,
4445
private LockService $lockService,
@@ -56,6 +57,7 @@ public function __construct(
5657
$this->registerResponder('xml', function ($data) {
5758
return $this->buildOCSResponse('xml', $data);
5859
});
60+
$this->logger = $logger;
5961
}
6062

6163

@@ -171,7 +173,7 @@ protected function fail(
171173
);
172174

173175
if ($log) {
174-
$this->log(2, $status . ' - ' . json_encode($data));
176+
$this->logger->warning('[warning] ' . $status . ' - ' . json_encode($data));
175177
}
176178

177179
return new DataResponse($data, $status);

lib/Service/LockService.php

+6-11
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use OCA\FilesLock\Exceptions\LockNotFoundException;
1515
use OCA\FilesLock\Exceptions\UnauthorizedUnlockException;
1616
use OCA\FilesLock\Model\FileLock;
17-
use OCA\FilesLock\Tools\Traits\TLogger;
1817
use OCA\FilesLock\Tools\Traits\TStringTools;
1918
use OCP\App\IAppManager;
2019
use OCP\EventDispatcher\IEventDispatcher;
@@ -34,8 +33,6 @@ class LockService {
3433

3534

3635
use TStringTools;
37-
use TLogger;
38-
3936

4037
private IUserManager $userManager;
4138
private IL10N $l10n;
@@ -78,8 +75,6 @@ public function __construct(
7875
$this->userSession = $userSession;
7976
$this->request = $request;
8077
$this->logger = $logger;
81-
82-
$this->setup('app', 'files_lock');
8378
}
8479

8580
/**
@@ -157,7 +152,7 @@ public function lock(LockContext $lockScope): FileLock {
157152
$known->setTimeout(
158153
$known->getETA() !== FileLock::ETA_INFINITE ? $known->getTimeout() - $known->getETA() + $this->configService->getTimeoutSeconds() : 0
159154
);
160-
$this->notice('extending existing lock', false, ['fileLock' => $known]);
155+
$this->logger->notice('extending existing lock', ['fileLock' => $known]);
161156
$this->locksRequest->update($known);
162157
$this->injectMetadata($known);
163158
return $known;
@@ -169,7 +164,7 @@ public function lock(LockContext $lockScope): FileLock {
169164
$lock = FileLock::fromLockScope($lockScope, $this->configService->getTimeoutSeconds());
170165
$this->generateToken($lock);
171166
$lock->setCreation(time());
172-
$this->notice('locking file', false, ['fileLock' => $lock]);
167+
$this->logger->notice('locking file', ['fileLock' => $lock]);
173168
$this->injectMetadata($lock);
174169
$this->locksRequest->save($lock);
175170
$this->propagateEtag($lockScope);
@@ -193,7 +188,7 @@ public function getAppName(string $appId): ?string {
193188
* @throws UnauthorizedUnlockException
194189
*/
195190
public function unlock(LockContext $lock, bool $force = false): FileLock {
196-
$this->notice('unlocking file', false, ['fileLock' => $lock]);
191+
$this->logger->notice('unlocking file', ['fileLock' => $lock]);
197192

198193
$known = $this->getLockFromFileId($lock->getNode()->getId());
199194
if (!$force) {
@@ -284,8 +279,8 @@ public function unlockFile(int $fileId, string $userId, bool $force = false, int
284279
public function getDeprecatedLocks(): array {
285280
$timeout = (int)$this->configService->getAppValue(ConfigService::LOCK_TIMEOUT);
286281
if ($timeout === 0) {
287-
$this->notice(
288-
'ConfigService::LOCK_TIMEOUT is not numerical, using default', true, ['current' => $timeout]
282+
$this->logger->notice(
283+
'ConfigService::LOCK_TIMEOUT is not numerical, using default', ['current' => $timeout, 'exception' => new \Exception()]
289284
);
290285
$timeout = (int)$this->configService->defaults[ConfigService::LOCK_TIMEOUT];
291286
}
@@ -381,7 +376,7 @@ function (FileLock $lock) {
381376
}, $locks
382377
);
383378

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

386381
$this->locksRequest->removeIds($ids);
387382
}

lib/Tools/Traits/TLogger.php

-181
This file was deleted.

0 commit comments

Comments
 (0)