Skip to content

Commit c11c436

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

File tree

3 files changed

+11
-215
lines changed

3 files changed

+11
-215
lines changed

lib/Controller/LockController.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
use OCA\FilesLock\Model\FileLock;
3939
use OCA\FilesLock\Service\FileService;
4040
use OCA\FilesLock\Service\LockService;
41-
use OCA\FilesLock\Tools\Traits\TLogger;
4241
use OCP\AppFramework\Http;
4342
use OCP\AppFramework\Http\DataResponse;
4443
use OCP\AppFramework\OCSController;
@@ -48,19 +47,21 @@
4847
use OCP\IL10N;
4948
use OCP\IRequest;
5049
use OCP\IUserSession;
50+
use Psr\Log\LoggerInterface;
5151

5252
/**
5353
* Class LockController
5454
*
5555
* @package OCA\FilesLock\Controller
5656
*/
5757
class LockController extends OCSController {
58-
use TLogger;
5958

6059
private int $ocsVersion;
60+
private LoggerInterface $logger;
6161

6262
public function __construct(
6363
IRequest $request,
64+
LoggerInterface $logger,
6465
private IUserSession $userSession,
6566
private FileService $fileService,
6667
private LockService $lockService,
@@ -82,6 +83,7 @@ public function __construct(
8283
$this->registerResponder('xml', function ($data) {
8384
return $this->buildOCSResponse('xml', $data);
8485
});
86+
$this->logger = $logger;
8587
}
8688

8789

@@ -197,7 +199,7 @@ protected function fail(
197199
);
198200

199201
if ($log) {
200-
$this->log(2, $status . ' - ' . json_encode($data));
202+
$this->logger->warning('[warning] ' . $status . ' - ' . json_encode($data));
201203
}
202204

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

lib/Service/LockService.php

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
use OCA\FilesLock\Exceptions\LockNotFoundException;
3737
use OCA\FilesLock\Exceptions\UnauthorizedUnlockException;
3838
use OCA\FilesLock\Model\FileLock;
39-
use OCA\FilesLock\Tools\Traits\TLogger;
4039
use OCA\FilesLock\Tools\Traits\TStringTools;
4140
use OCP\App\IAppManager;
4241
use OCP\EventDispatcher\IEventDispatcher;
@@ -56,8 +55,6 @@ class LockService {
5655

5756

5857
use TStringTools;
59-
use TLogger;
60-
6158

6259
private IUserManager $userManager;
6360
private IL10N $l10n;
@@ -100,8 +97,6 @@ public function __construct(
10097
$this->userSession = $userSession;
10198
$this->request = $request;
10299
$this->logger = $logger;
103-
104-
$this->setup('app', 'files_lock');
105100
}
106101

107102
/**
@@ -179,7 +174,7 @@ public function lock(LockContext $lockScope): FileLock {
179174
$known->setTimeout(
180175
$known->getETA() !== FileLock::ETA_INFINITE ? $known->getTimeout() - $known->getETA() + $this->configService->getTimeoutSeconds() : 0
181176
);
182-
$this->notice('extending existing lock', false, ['fileLock' => $known]);
177+
$this->logger->notice('extending existing lock', ['fileLock' => $known]);
183178
$this->locksRequest->update($known);
184179
$this->injectMetadata($known);
185180
return $known;
@@ -191,7 +186,7 @@ public function lock(LockContext $lockScope): FileLock {
191186
$lock = FileLock::fromLockScope($lockScope, $this->configService->getTimeoutSeconds());
192187
$this->generateToken($lock);
193188
$lock->setCreation(time());
194-
$this->notice('locking file', false, ['fileLock' => $lock]);
189+
$this->logger->notice('locking file', ['fileLock' => $lock]);
195190
$this->injectMetadata($lock);
196191
$this->locksRequest->save($lock);
197192
$this->propagateEtag($lockScope);
@@ -215,7 +210,7 @@ public function getAppName(string $appId): ?string {
215210
* @throws UnauthorizedUnlockException
216211
*/
217212
public function unlock(LockContext $lock, bool $force = false): FileLock {
218-
$this->notice('unlocking file', false, ['fileLock' => $lock]);
213+
$this->logger->notice('unlocking file', ['fileLock' => $lock]);
219214

220215
$known = $this->getLockFromFileId($lock->getNode()->getId());
221216
if (!$force) {
@@ -306,8 +301,8 @@ public function unlockFile(int $fileId, string $userId, bool $force = false, int
306301
public function getDeprecatedLocks(): array {
307302
$timeout = (int)$this->configService->getAppValue(ConfigService::LOCK_TIMEOUT);
308303
if ($timeout === 0) {
309-
$this->notice(
310-
'ConfigService::LOCK_TIMEOUT is not numerical, using default', true, ['current' => $timeout]
304+
$this->logger->notice(
305+
'ConfigService::LOCK_TIMEOUT is not numerical, using default', ['current' => $timeout, 'exception' => new \Exception()]
311306
);
312307
$timeout = (int)$this->configService->defaults[ConfigService::LOCK_TIMEOUT];
313308
}
@@ -403,7 +398,7 @@ function (FileLock $lock) {
403398
}, $locks
404399
);
405400

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

408403
$this->locksRequest->removeIds($ids);
409404
}

lib/Tools/Traits/TLogger.php

Lines changed: 0 additions & 201 deletions
This file was deleted.

0 commit comments

Comments
 (0)