diff options
Diffstat (limited to 'lib/private')
42 files changed, 171 insertions, 335 deletions
diff --git a/lib/private/DB/QueryBuilder/QueryBuilder.php b/lib/private/DB/QueryBuilder/QueryBuilder.php index de326a2a317..c2f99143660 100644 --- a/lib/private/DB/QueryBuilder/QueryBuilder.php +++ b/lib/private/DB/QueryBuilder/QueryBuilder.php @@ -53,7 +53,7 @@ use OCP\DB\QueryBuilder\ILiteral; use OCP\DB\QueryBuilder\IParameter; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\DB\QueryBuilder\IQueryFunction; -use OCP\ILogger; +use Psr\Log\LoggerInterface; class QueryBuilder implements IQueryBuilder { @@ -63,8 +63,7 @@ class QueryBuilder implements IQueryBuilder { /** @var SystemConfig */ private $systemConfig; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; /** @var \Doctrine\DBAL\Query\QueryBuilder */ private $queryBuilder; @@ -83,9 +82,8 @@ class QueryBuilder implements IQueryBuilder { * * @param ConnectionAdapter $connection * @param SystemConfig $systemConfig - * @param ILogger $logger */ - public function __construct(ConnectionAdapter $connection, SystemConfig $systemConfig, ILogger $logger) { + public function __construct(ConnectionAdapter $connection, SystemConfig $systemConfig, LoggerInterface $logger) { $this->connection = $connection; $this->systemConfig = $systemConfig; $this->logger = $logger; @@ -229,8 +227,7 @@ class QueryBuilder implements IQueryBuilder { } } catch (\Error $e) { // likely an error during conversion of $value to string - $this->logger->debug('DB QueryBuilder: error trying to log SQL query'); - $this->logger->logException($e); + $this->logger->debug('DB QueryBuilder: error trying to log SQL query', ['exception' => $e]); } } @@ -245,11 +242,10 @@ class QueryBuilder implements IQueryBuilder { if (empty($hasSelectAll) === empty($hasSelectSpecific)) { $exception = new QueryException('Query is selecting * and specific values in the same query. This is not supported in Oracle.'); - $this->logger->logException($exception, [ - 'message' => 'Query is selecting * and specific values in the same query. This is not supported in Oracle.', + $this->logger->error($exception->getMessage(), [ 'query' => $this->getSQL(), - 'level' => ILogger::ERROR, 'app' => 'core', + 'exception' => $exception, ]); } } @@ -266,21 +262,19 @@ class QueryBuilder implements IQueryBuilder { if ($hasTooLargeArrayParameter) { $exception = new QueryException('More than 1000 expressions in a list are not allowed on Oracle.'); - $this->logger->logException($exception, [ - 'message' => 'More than 1000 expressions in a list are not allowed on Oracle.', + $this->logger->error($exception->getMessage(), [ 'query' => $this->getSQL(), - 'level' => ILogger::ERROR, 'app' => 'core', + 'exception' => $exception, ]); } if ($numberOfParameters > 65535) { $exception = new QueryException('The number of parameters must not exceed 65535. Restriction by PostgreSQL.'); - $this->logger->logException($exception, [ - 'message' => 'The number of parameters must not exceed 65535. Restriction by PostgreSQL.', + $this->logger->error($exception->getMessage(), [ 'query' => $this->getSQL(), - 'level' => ILogger::ERROR, 'app' => 'core', + 'exception' => $exception, ]); } diff --git a/lib/private/Encryption/EncryptionWrapper.php b/lib/private/Encryption/EncryptionWrapper.php index e3dc539dd00..f2803fa5ff8 100644 --- a/lib/private/Encryption/EncryptionWrapper.php +++ b/lib/private/Encryption/EncryptionWrapper.php @@ -30,7 +30,6 @@ use OC\Files\View; use OC\Memcache\ArrayCache; use OCP\Files\Mount\IMountPoint; use OCP\Files\Storage; -use OCP\ILogger; use Psr\Log\LoggerInterface; /** @@ -48,19 +47,14 @@ class EncryptionWrapper { /** @var Manager */ private $manager; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; /** * EncryptionWrapper constructor. - * - * @param ArrayCache $arrayCache - * @param Manager $manager - * @param ILogger $logger */ public function __construct(ArrayCache $arrayCache, Manager $manager, - ILogger $logger + LoggerInterface $logger ) { $this->arrayCache = $arrayCache; $this->manager = $manager; @@ -101,7 +95,7 @@ class EncryptionWrapper { Filesystem::getMountManager(), $this->manager, $fileHelper, - \OC::$server->get(LoggerInterface::class), + $this->logger, $uid ); return new Encryption( diff --git a/lib/private/Encryption/Manager.php b/lib/private/Encryption/Manager.php index 55578ee25f4..5788da990d5 100644 --- a/lib/private/Encryption/Manager.php +++ b/lib/private/Encryption/Manager.php @@ -34,7 +34,7 @@ use OCP\Encryption\IEncryptionModule; use OCP\Encryption\IManager; use OCP\IConfig; use OCP\IL10N; -use OCP\ILogger; +use Psr\Log\LoggerInterface; class Manager implements IManager { @@ -44,8 +44,7 @@ class Manager implements IManager { /** @var IConfig */ protected $config; - /** @var ILogger */ - protected $logger; + protected LoggerInterface $logger; /** @var Il10n */ protected $l; @@ -59,15 +58,7 @@ class Manager implements IManager { /** @var ArrayCache */ protected $arrayCache; - /** - * @param IConfig $config - * @param ILogger $logger - * @param IL10N $l10n - * @param View $rootView - * @param Util $util - * @param ArrayCache $arrayCache - */ - public function __construct(IConfig $config, ILogger $logger, IL10N $l10n, View $rootView, Util $util, ArrayCache $arrayCache) { + public function __construct(IConfig $config, LoggerInterface $logger, IL10N $l10n, View $rootView, Util $util, ArrayCache $arrayCache) { $this->encryptionModules = []; $this->config = $config; $this->logger = $logger; diff --git a/lib/private/EventDispatcher/GenericEventWrapper.php b/lib/private/EventDispatcher/GenericEventWrapper.php index 3574bc8bb83..76ae7f0ec7d 100644 --- a/lib/private/EventDispatcher/GenericEventWrapper.php +++ b/lib/private/EventDispatcher/GenericEventWrapper.php @@ -26,13 +26,12 @@ declare(strict_types=1); */ namespace OC\EventDispatcher; -use OCP\ILogger; +use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\GenericEvent; class GenericEventWrapper extends GenericEvent { - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; /** @var GenericEvent */ private $event; @@ -43,7 +42,7 @@ class GenericEventWrapper extends GenericEvent { /** @var bool */ private $deprecationNoticeLogged = false; - public function __construct(ILogger $logger, string $eventName, ?GenericEvent $event) { + public function __construct(LoggerInterface $logger, string $eventName, ?GenericEvent $event) { parent::__construct($eventName); $this->logger = $logger; $this->event = $event; diff --git a/lib/private/EventDispatcher/SymfonyAdapter.php b/lib/private/EventDispatcher/SymfonyAdapter.php index 6cd636afc55..a12e932e380 100644 --- a/lib/private/EventDispatcher/SymfonyAdapter.php +++ b/lib/private/EventDispatcher/SymfonyAdapter.php @@ -27,12 +27,12 @@ declare(strict_types=1); */ namespace OC\EventDispatcher; -use Symfony\Component\EventDispatcher\GenericEvent; -use function is_callable; use OCP\EventDispatcher\Event; -use OCP\ILogger; +use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Symfony\Component\EventDispatcher\GenericEvent; +use function is_callable; use function is_object; use function is_string; @@ -43,13 +43,12 @@ class SymfonyAdapter implements EventDispatcherInterface { /** @var EventDispatcher */ private $eventDispatcher; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; /** * @deprecated 20.0.0 */ - public function __construct(EventDispatcher $eventDispatcher, ILogger $logger) { + public function __construct(EventDispatcher $eventDispatcher, LoggerInterface $logger) { $this->eventDispatcher = $eventDispatcher; $this->logger = $logger; } diff --git a/lib/private/Federation/CloudFederationProviderManager.php b/lib/private/Federation/CloudFederationProviderManager.php index c19ca8429ca..c25d4a40363 100644 --- a/lib/private/Federation/CloudFederationProviderManager.php +++ b/lib/private/Federation/CloudFederationProviderManager.php @@ -32,7 +32,7 @@ use OCP\Federation\ICloudFederationProviderManager; use OCP\Federation\ICloudFederationShare; use OCP\Federation\ICloudIdManager; use OCP\Http\Client\IClientService; -use OCP\ILogger; +use Psr\Log\LoggerInterface; /** * Class Manager @@ -55,8 +55,7 @@ class CloudFederationProviderManager implements ICloudFederationProviderManager /** @var ICloudIdManager */ private $cloudIdManager; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; /** @var array cache OCM end-points */ private $ocmEndPoints = []; @@ -69,12 +68,11 @@ class CloudFederationProviderManager implements ICloudFederationProviderManager * @param IAppManager $appManager * @param IClientService $httpClientService * @param ICloudIdManager $cloudIdManager - * @param ILogger $logger */ public function __construct(IAppManager $appManager, IClientService $httpClientService, ICloudIdManager $cloudIdManager, - ILogger $logger) { + LoggerInterface $logger) { $this->cloudFederationProvider = []; $this->appManager = $appManager; $this->httpClientService = $httpClientService; @@ -156,7 +154,7 @@ class CloudFederationProviderManager implements ICloudFederationProviderManager // we re-throw the exception and fall back to the old behaviour. // (flat re-shares has been introduced in Nextcloud 9.1) if ($e->getCode() === Http::STATUS_INTERNAL_SERVER_ERROR) { - $this->logger->debug($e->getMessage()); + $this->logger->debug($e->getMessage(), ['exception' => $e]); throw $e; } } @@ -190,7 +188,7 @@ class CloudFederationProviderManager implements ICloudFederationProviderManager } } catch (\Exception $e) { // log the error and return false - $this->logger->error('error while sending notification for federated share: ' . $e->getMessage()); + $this->logger->error('error while sending notification for federated share: ' . $e->getMessage(), ['exception' => $e]); } return false; diff --git a/lib/private/Files/Cache/CacheQueryBuilder.php b/lib/private/Files/Cache/CacheQueryBuilder.php index 87a1f940f20..b5a9101877c 100644 --- a/lib/private/Files/Cache/CacheQueryBuilder.php +++ b/lib/private/Files/Cache/CacheQueryBuilder.php @@ -29,7 +29,7 @@ use OC\DB\QueryBuilder\QueryBuilder; use OC\SystemConfig; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IDBConnection; -use OCP\ILogger; +use Psr\Log\LoggerInterface; /** * Query builder with commonly used helpers for filecache queries @@ -37,7 +37,7 @@ use OCP\ILogger; class CacheQueryBuilder extends QueryBuilder { private $alias = null; - public function __construct(IDBConnection $connection, SystemConfig $systemConfig, ILogger $logger) { + public function __construct(IDBConnection $connection, SystemConfig $systemConfig, LoggerInterface $logger) { parent::__construct($connection, $systemConfig, $logger); } diff --git a/lib/private/Files/Cache/QuerySearchHelper.php b/lib/private/Files/Cache/QuerySearchHelper.php index e065e95e4fd..3bf9abf3524 100644 --- a/lib/private/Files/Cache/QuerySearchHelper.php +++ b/lib/private/Files/Cache/QuerySearchHelper.php @@ -34,7 +34,7 @@ use OCP\Files\IMimeTypeLoader; use OCP\Files\Search\ISearchBinaryOperator; use OCP\Files\Search\ISearchQuery; use OCP\IDBConnection; -use OCP\ILogger; +use Psr\Log\LoggerInterface; class QuerySearchHelper { @@ -44,8 +44,7 @@ class QuerySearchHelper { private $connection; /** @var SystemConfig */ private $systemConfig; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; /** @var SearchBuilder */ private $searchBuilder; /** @var QueryOptimizer */ @@ -55,7 +54,7 @@ class QuerySearchHelper { IMimeTypeLoader $mimetypeLoader, IDBConnection $connection, SystemConfig $systemConfig, - ILogger $logger, + LoggerInterface $logger, SearchBuilder $searchBuilder, QueryOptimizer $queryOptimizer ) { diff --git a/lib/private/Files/Config/UserMountCache.php b/lib/private/Files/Config/UserMountCache.php index dc2640361e7..538f48012e2 100644 --- a/lib/private/Files/Config/UserMountCache.php +++ b/lib/private/Files/Config/UserMountCache.php @@ -38,9 +38,9 @@ use OCP\Files\Mount\IMountPoint; use OCP\Files\NotFoundException; use OCP\ICache; use OCP\IDBConnection; -use OCP\ILogger; use OCP\IUser; use OCP\IUserManager; +use Psr\Log\LoggerInterface; /** * Cache mounts points per user in the cache so we can easilly look them up @@ -64,10 +64,7 @@ class UserMountCache implements IUserMountCache { **/ private $mountsForUsers; - /** - * @var ILogger - */ - private $logger; + private LoggerInterface $logger; /** * @var ICache @@ -76,12 +73,8 @@ class UserMountCache implements IUserMountCache { /** * UserMountCache constructor. - * - * @param IDBConnection $connection - * @param IUserManager $userManager - * @param ILogger $logger */ - public function __construct(IDBConnection $connection, IUserManager $userManager, ILogger $logger) { + public function __construct(IDBConnection $connection, IUserManager $userManager, LoggerInterface $logger) { $this->connection = $connection; $this->userManager = $userManager; $this->logger = $logger; diff --git a/lib/private/Files/Mount/ObjectStorePreviewCacheMountProvider.php b/lib/private/Files/Mount/ObjectStorePreviewCacheMountProvider.php index 0043503f2cd..3a20afba5a5 100644 --- a/lib/private/Files/Mount/ObjectStorePreviewCacheMountProvider.php +++ b/lib/private/Files/Mount/ObjectStorePreviewCacheMountProvider.php @@ -31,18 +31,17 @@ use OC\Files\Storage\Wrapper\Jail; use OCP\Files\Config\IRootMountProvider; use OCP\Files\Storage\IStorageFactory; use OCP\IConfig; -use OCP\ILogger; +use Psr\Log\LoggerInterface; /** * Mount provider for object store app data folder for previews */ class ObjectStorePreviewCacheMountProvider implements IRootMountProvider { - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; /** @var IConfig */ private $config; - public function __construct(ILogger $logger, IConfig $config) { + public function __construct(LoggerInterface $logger, IConfig $config) { $this->logger = $logger; $this->config = $config; } diff --git a/lib/private/Files/Node/Root.php b/lib/private/Files/Node/Root.php index 88ac4a31d34..ab44d179d69 100644 --- a/lib/private/Files/Node/Root.php +++ b/lib/private/Files/Node/Root.php @@ -44,9 +44,9 @@ use OCP\Files\Events\Node\FilesystemTornDownEvent; use OCP\Files\IRootFolder; use OCP\Files\NotFoundException; use OCP\Files\NotPermittedException; -use OCP\ILogger; use OCP\IUser; use OCP\IUserManager; +use Psr\Log\LoggerInterface; /** * Class Root @@ -73,7 +73,7 @@ class Root extends Folder implements IRootFolder { private ?IUser $user; private CappedMemoryCache $userFolderCache; private IUserMountCache $userMountCache; - private ILogger $logger; + private LoggerInterface $logger; private IUserManager $userManager; private IEventDispatcher $eventDispatcher; @@ -81,16 +81,13 @@ class Root extends Folder implements IRootFolder { * @param Manager $manager * @param View $view * @param IUser|null $user - * @param IUserMountCache $userMountCache - * @param ILogger $logger - * @param IUserManager $userManager */ public function __construct( $manager, $view, $user, IUserMountCache $userMountCache, - ILogger $logger, + LoggerInterface $logger, IUserManager $userManager, IEventDispatcher $eventDispatcher ) { diff --git a/lib/private/Files/ObjectStore/SwiftFactory.php b/lib/private/Files/ObjectStore/SwiftFactory.php index df4b5a93678..bd75ccada2e 100644 --- a/lib/private/Files/ObjectStore/SwiftFactory.php +++ b/lib/private/Files/ObjectStore/SwiftFactory.php @@ -40,7 +40,6 @@ use GuzzleHttp\HandlerStack; use OCP\Files\StorageAuthException; use OCP\Files\StorageNotAvailableException; use OCP\ICache; -use OCP\ILogger; use OpenStack\Common\Auth\Token; use OpenStack\Common\Error\BadResponseError; use OpenStack\Common\Transport\Utils as TransportUtils; @@ -50,13 +49,14 @@ use OpenStack\Identity\v3\Service as IdentityV3Service; use OpenStack\ObjectStore\v1\Models\Container; use OpenStack\OpenStack; use Psr\Http\Message\RequestInterface; +use Psr\Log\LoggerInterface; class SwiftFactory { private $cache; private $params; /** @var Container|null */ private $container = null; - private $logger; + private LoggerInterface $logger; public const DEFAULT_OPTIONS = [ 'autocreate' => false, @@ -65,7 +65,7 @@ class SwiftFactory { 'catalogType' => 'object-store' ]; - public function __construct(ICache $cache, array $params, ILogger $logger) { + public function __construct(ICache $cache, array $params, LoggerInterface $logger) { $this->cache = $cache; $this->params = $params; $this->logger = $logger; @@ -203,7 +203,7 @@ class SwiftFactory { $this->logger->debug('Cached token for swift expired'); } } catch (\Exception $e) { - $this->logger->logException($e); + $this->logger->error($e->getMessage(), ['exception' => $e]); } } } @@ -279,7 +279,7 @@ class SwiftFactory { /** @var RequestInterface $request */ $request = $e->getRequest(); $host = $request->getUri()->getHost() . ':' . $request->getUri()->getPort(); - \OC::$server->getLogger()->error("Can't connect to object storage server at $host"); + $this->logger->error("Can't connect to object storage server at $host", ['exception' => $e]); throw new StorageNotAvailableException("Can't connect to object storage server at $host", StorageNotAvailableException::STATUS_ERROR, $e); } } diff --git a/lib/private/Files/Storage/Wrapper/Encryption.php b/lib/private/Files/Storage/Wrapper/Encryption.php index 75611d1ab0f..a03dd0ba441 100644 --- a/lib/private/Files/Storage/Wrapper/Encryption.php +++ b/lib/private/Files/Storage/Wrapper/Encryption.php @@ -50,7 +50,7 @@ use OCP\Encryption\Keys\IStorage; use OCP\Files\Cache\ICacheEntry; use OCP\Files\Mount\IMountPoint; use OCP\Files\Storage; -use OCP\ILogger; +use Psr\Log\LoggerInterface; class Encryption extends Wrapper { use LocalTempFileTrait; @@ -64,8 +64,7 @@ class Encryption extends Wrapper { /** @var \OCP\Encryption\IManager */ private $encryptionManager; - /** @var \OCP\ILogger */ - private $logger; + private LoggerInterface $logger; /** @var string */ private $uid; @@ -96,27 +95,18 @@ class Encryption extends Wrapper { /** * @param array $parameters - * @param IManager $encryptionManager - * @param Util $util - * @param ILogger $logger - * @param IFile $fileHelper - * @param string $uid - * @param IStorage $keyStorage - * @param Update $update - * @param Manager $mountManager - * @param ArrayCache $arrayCache */ public function __construct( $parameters, - IManager $encryptionManager = null, - Util $util = null, - ILogger $logger = null, - IFile $fileHelper = null, - $uid = null, - IStorage $keyStorage = null, - Update $update = null, - Manager $mountManager = null, - ArrayCache $arrayCache = null + IManager $encryptionManager, + Util $util, + LoggerInterface $logger, + IFile $fileHelper, + string $uid, + IStorage $keyStorage, + Update $update, + Manager $mountManager, + ArrayCache $arrayCache ) { $this->mountPoint = $parameters['mountPoint']; $this->mount = $parameters['mount']; @@ -448,9 +438,8 @@ class Encryption extends Wrapper { } } } catch (ModuleDoesNotExistsException $e) { - $this->logger->logException($e, [ - 'message' => 'Encryption module "' . $encryptionModuleId . '" not found, file will be stored unencrypted', - 'level' => ILogger::WARN, + $this->logger->warning('Encryption module "' . $encryptionModuleId . '" not found, file will be stored unencrypted', [ + 'exception' => $e, 'app' => 'core', ]); } @@ -503,8 +492,7 @@ class Encryption extends Wrapper { try { $result = $this->fixUnencryptedSize($path, $size, $unencryptedSize); } catch (\Exception $e) { - $this->logger->error('Couldn\'t re-calculate unencrypted size for ' . $path); - $this->logger->logException($e); + $this->logger->error('Couldn\'t re-calculate unencrypted size for ' . $path, ['exception' => $e]); } unset($this->fixUnencryptedSizeOf[$this->getFullPath($path)]); } diff --git a/lib/private/Files/Type/Detection.php b/lib/private/Files/Type/Detection.php index bd2bfb5f939..4cade024460 100644 --- a/lib/private/Files/Type/Detection.php +++ b/lib/private/Files/Type/Detection.php @@ -42,8 +42,8 @@ declare(strict_types=1); namespace OC\Files\Type; use OCP\Files\IMimeTypeDetector; -use OCP\ILogger; use OCP\IURLGenerator; +use Psr\Log\LoggerInterface; /** * Class Detection @@ -66,8 +66,7 @@ class Detection implements IMimeTypeDetector { /** @var IURLGenerator */ private $urlGenerator; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; /** @var string */ private $customConfigDir; @@ -75,14 +74,8 @@ class Detection implements IMimeTypeDetector { /** @var string */ private $defaultConfigDir; - /** - * @param IURLGenerator $urlGenerator - * @param ILogger $logger - * @param string $customConfigDir - * @param string $defaultConfigDir - */ public function __construct(IURLGenerator $urlGenerator, - ILogger $logger, + LoggerInterface $logger, string $customConfigDir, string $defaultConfigDir) { $this->urlGenerator = $urlGenerator; diff --git a/lib/private/Files/Utils/Scanner.php b/lib/private/Files/Utils/Scanner.php index 5b633617608..dc220bc710d 100644 --- a/lib/private/Files/Utils/Scanner.php +++ b/lib/private/Files/Utils/Scanner.php @@ -48,7 +48,7 @@ use OCP\Files\NotFoundException; use OCP\Files\Storage\IStorage; use OCP\Files\StorageNotAvailableException; use OCP\IDBConnection; -use OCP\ILogger; +use Psr\Log\LoggerInterface; /** * Class Scanner @@ -71,8 +71,7 @@ class Scanner extends PublicEmitter { /** @var IEventDispatcher */ private $dispatcher; - /** @var ILogger */ - protected $logger; + protected LoggerInterface $logger; /** * Whether to use a DB transaction @@ -92,9 +91,8 @@ class Scanner extends PublicEmitter { * @param string $user * @param IDBConnection|null $db * @param IEventDispatcher $dispatcher - * @param ILogger $logger */ - public function __construct($user, $db, IEventDispatcher $dispatcher, ILogger $logger) { + public function __construct($user, $db, IEventDispatcher $dispatcher, LoggerInterface $logger) { $this->user = $user; $this->db = $db; $this->dispatcher = $dispatcher; @@ -263,8 +261,7 @@ class Scanner extends PublicEmitter { } $propagator->commitBatch(); } catch (StorageNotAvailableException $e) { - $this->logger->error('Storage ' . $storage->getId() . ' not available'); - $this->logger->logException($e); + $this->logger->error('Storage ' . $storage->getId() . ' not available', ['exception' => $e]); $this->emit('\OC\Files\Utils\Scanner', 'StorageNotAvailable', [$e]); } if ($this->useTransaction) { diff --git a/lib/private/Group/Manager.php b/lib/private/Group/Manager.php index e1bd009e79c..28f7a400b41 100644 --- a/lib/private/Group/Manager.php +++ b/lib/private/Group/Manager.php @@ -44,8 +44,8 @@ use OCP\EventDispatcher\IEventDispatcher; use OCP\GroupInterface; use OCP\IGroup; use OCP\IGroupManager; -use OCP\ILogger; use OCP\IUser; +use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** @@ -71,8 +71,7 @@ class Manager extends PublicEmitter implements IGroupManager { private $userManager; /** @var EventDispatcherInterface */ private $dispatcher; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; /** @var \OC\Group\Group[] */ private $cachedGroups = []; @@ -83,14 +82,9 @@ class Manager extends PublicEmitter implements IGroupManager { /** @var \OC\SubAdmin */ private $subAdmin = null; - /** - * @param \OC\User\Manager $userManager - * @param EventDispatcherInterface $dispatcher - * @param ILogger $logger - */ public function __construct(\OC\User\Manager $userManager, EventDispatcherInterface $dispatcher, - ILogger $logger) { + LoggerInterface $logger) { $this->userManager = $userManager; $this->dispatcher = $dispatcher; $this->logger = $logger; diff --git a/lib/private/Http/Client/Client.php b/lib/private/Http/Client/Client.php index 673f566e354..3ba85a2dd9f 100644 --- a/lib/private/Http/Client/Client.php +++ b/lib/private/Http/Client/Client.php @@ -39,7 +39,6 @@ use OCP\Http\Client\IClient; use OCP\Http\Client\IResponse; use OCP\ICertificateManager; use OCP\IConfig; -use OCP\ILogger; /** * Class Client @@ -51,8 +50,6 @@ class Client implements IClient { private $client; /** @var IConfig */ private $config; - /** @var ILogger */ - private $logger; /** @var ICertificateManager */ private $certificateManager; /** @var LocalAddressChecker */ @@ -60,13 +57,11 @@ class Client implements IClient { public function __construct( IConfig $config, - ILogger $logger, ICertificateManager $certificateManager, GuzzleClient $client, LocalAddressChecker $localAddressChecker ) { $this->config = $config; - $this->logger = $logger; $this->client = $client; $this->certificateManager = $certificateManager; $this->localAddressChecker = $localAddressChecker; diff --git a/lib/private/Http/Client/ClientService.php b/lib/private/Http/Client/ClientService.php index d1aed2d7883..e868d4af7a5 100644 --- a/lib/private/Http/Client/ClientService.php +++ b/lib/private/Http/Client/ClientService.php @@ -33,7 +33,6 @@ use OCP\Http\Client\IClient; use OCP\Http\Client\IClientService; use OCP\ICertificateManager; use OCP\IConfig; -use OCP\ILogger; /** * Class ClientService @@ -43,8 +42,6 @@ use OCP\ILogger; class ClientService implements IClientService { /** @var IConfig */ private $config; - /** @var ILogger */ - private $logger; /** @var ICertificateManager */ private $certificateManager; /** @var DnsPinMiddleware */ @@ -53,12 +50,10 @@ class ClientService implements IClientService { private $localAddressChecker; public function __construct(IConfig $config, - ILogger $logger, ICertificateManager $certificateManager, DnsPinMiddleware $dnsPinMiddleware, LocalAddressChecker $localAddressChecker) { $this->config = $config; - $this->logger = $logger; $this->certificateManager = $certificateManager; $this->dnsPinMiddleware = $dnsPinMiddleware; $this->localAddressChecker = $localAddressChecker; @@ -76,7 +71,6 @@ class ClientService implements IClientService { return new Client( $this->config, - $this->logger, $this->certificateManager, $client, $this->localAddressChecker diff --git a/lib/private/Http/Client/LocalAddressChecker.php b/lib/private/Http/Client/LocalAddressChecker.php index c534c5971d1..2789b1b5935 100644 --- a/lib/private/Http/Client/LocalAddressChecker.php +++ b/lib/private/Http/Client/LocalAddressChecker.php @@ -25,14 +25,13 @@ declare(strict_types=1); */ namespace OC\Http\Client; -use OCP\ILogger; use OCP\Http\Client\LocalServerException; +use Psr\Log\LoggerInterface; class LocalAddressChecker { - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; - public function __construct(ILogger $logger) { + public function __construct(LoggerInterface $logger) { $this->logger = $logger; } diff --git a/lib/private/Lock/DBLockingProvider.php b/lib/private/Lock/DBLockingProvider.php index 1ea78d047d2..5eb03ad856b 100644 --- a/lib/private/Lock/DBLockingProvider.php +++ b/lib/private/Lock/DBLockingProvider.php @@ -31,9 +31,9 @@ use OC\DB\QueryBuilder\Literal; use OCP\AppFramework\Utility\ITimeFactory; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\IDBConnection; -use OCP\ILogger; use OCP\Lock\ILockingProvider; use OCP\Lock\LockedException; +use Psr\Log\LoggerInterface; /** * Locking provider that stores the locks in the database @@ -44,10 +44,7 @@ class DBLockingProvider extends AbstractLockingProvider { */ private $connection; - /** - * @var \OCP\ILogger - */ - private $logger; + private LoggerInterface $logger; /** * @var \OCP\AppFramework\Utility\ITimeFactory @@ -104,15 +101,11 @@ class DBLockingProvider extends AbstractLockingProvider { } /** - * @param \OCP\IDBConnection $connection - * @param \OCP\ILogger $logger - * @param \OCP\AppFramework\Utility\ITimeFactory $timeFactory - * @param int $ttl * @param bool $cacheSharedLocks */ public function __construct( IDBConnection $connection, - ILogger $logger, + LoggerInterface $logger, ITimeFactory $timeFactory, int $ttl = 3600, $cacheSharedLocks = true diff --git a/lib/private/Mail/Mailer.php b/lib/private/Mail/Mailer.php index 61f506d2676..2f3480498be 100644 --- a/lib/private/Mail/Mailer.php +++ b/lib/private/Mail/Mailer.php @@ -41,7 +41,6 @@ use OCP\Defaults; use OCP\EventDispatcher\IEventDispatcher; use OCP\IConfig; use OCP\IL10N; -use OCP\ILogger; use OCP\IURLGenerator; use OCP\L10N\IFactory; use OCP\Mail\Events\BeforeMessageSent; @@ -49,6 +48,7 @@ use OCP\Mail\IAttachment; use OCP\Mail\IEMailTemplate; use OCP\Mail\IMailer; use OCP\Mail\IMessage; +use Psr\Log\LoggerInterface; /** * Class Mailer provides some basic functions to create a mail message that can be used in combination with @@ -73,8 +73,7 @@ class Mailer implements IMailer { private $instance = null; /** @var IConfig */ private $config; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; /** @var Defaults */ private $defaults; /** @var IURLGenerator */ @@ -86,16 +85,8 @@ class Mailer implements IMailer { /** @var IFactory */ private $l10nFactory; - /** - * @param IConfig $config - * @param ILogger $logger - * @param Defaults $defaults - * @param IURLGenerator $urlGenerator - * @param IL10N $l10n - * @param IEventDispatcher $dispatcher - */ public function __construct(IConfig $config, - ILogger $logger, + LoggerInterface $logger, Defaults $defaults, IURLGenerator $urlGenerator, IL10N $l10n, diff --git a/lib/private/Memcache/Factory.php b/lib/private/Memcache/Factory.php index 7791c4beae9..73206aac011 100644 --- a/lib/private/Memcache/Factory.php +++ b/lib/private/Memcache/Factory.php @@ -33,8 +33,8 @@ namespace OC\Memcache; use OCP\ICache; use OCP\ICacheFactory; -use OCP\ILogger; use OCP\IMemcache; +use Psr\Log\LoggerInterface; class Factory implements ICacheFactory { public const NULL_CACHE = NullCache::class; @@ -44,10 +44,7 @@ class Factory implements ICacheFactory { */ private $globalPrefix; - /** - * @var ILogger $logger - */ - private $logger; + private LoggerInterface $logger; /** * @var string $localCacheClass @@ -67,16 +64,14 @@ class Factory implements ICacheFactory { /** @var string */ private $logFile; - /** - * @param string $globalPrefix - * @param ILogger $logger - * @param string|null $localCacheClass - * @param string|null $distributedCacheClass - * @param string|null $lockingCacheClass - * @param string $logFile - */ - public function __construct(string $globalPrefix, ILogger $logger, - $localCacheClass = null, $distributedCacheClass = null, $lockingCacheClass = null, string $logFile = '') { + public function __construct( + string $globalPrefix, + LoggerInterface $logger, + ?string $localCacheClass = null, + ?string $distributedCacheClass = null, + ?string $lockingCacheClass = null, + string $logFile = '' + ) { $this->logger = $logger; $this->logFile = $logFile; $this->globalPrefix = $globalPrefix; diff --git a/lib/private/Migration/SimpleOutput.php b/lib/private/Migration/SimpleOutput.php index 5024fdac585..6994f6de357 100644 --- a/lib/private/Migration/SimpleOutput.php +++ b/lib/private/Migration/SimpleOutput.php @@ -21,8 +21,8 @@ */ namespace OC\Migration; -use OCP\ILogger; use OCP\Migration\IOutput; +use Psr\Log\LoggerInterface; /** * Class SimpleOutput @@ -34,11 +34,10 @@ use OCP\Migration\IOutput; */ class SimpleOutput implements IOutput { - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; private $appName; - public function __construct(ILogger $logger, $appName) { + public function __construct(LoggerInterface $logger, $appName) { $this->logger = $logger; $this->appName = $appName; } diff --git a/lib/private/Repair/Collation.php b/lib/private/Repair/Collation.php index e949c261b80..25e85f00af8 100644 --- a/lib/private/Repair/Collation.php +++ b/lib/private/Repair/Collation.php @@ -30,16 +30,15 @@ use Doctrine\DBAL\Exception\DriverException; use Doctrine\DBAL\Platforms\MySQLPlatform; use OCP\IConfig; use OCP\IDBConnection; -use OCP\ILogger; use OCP\Migration\IOutput; use OCP\Migration\IRepairStep; +use Psr\Log\LoggerInterface; class Collation implements IRepairStep { /** @var IConfig */ protected $config; - /** @var ILogger */ - protected $logger; + protected LoggerInterface $logger; /** @var IDBConnection */ protected $connection; @@ -48,12 +47,14 @@ class Collation implements IRepairStep { protected $ignoreFailures; /** - * @param IConfig $config - * @param ILogger $logger - * @param IDBConnection $connection * @param bool $ignoreFailures */ - public function __construct(IConfig $config, ILogger $logger, IDBConnection $connection, $ignoreFailures) { + public function __construct( + IConfig $config, + LoggerInterface $logger, + IDBConnection $connection, + $ignoreFailures + ) { $this->connection = $connection; $this->config = $config; $this->logger = $logger; @@ -83,7 +84,7 @@ class Collation implements IRepairStep { $query->execute(); } catch (DriverException $e) { // Just log this - $this->logger->logException($e); + $this->logger->error($e->getMessage(), ['exception' => $e]); if (!$this->ignoreFailures) { throw $e; } @@ -95,7 +96,7 @@ class Collation implements IRepairStep { $query->execute(); } catch (DriverException $e) { // Just log this - $this->logger->logException($e); + $this->logger->error($e->getMessage(), ['exception' => $e]); if (!$this->ignoreFailures) { throw $e; } diff --git a/lib/private/Repair/NC16/CleanupCardDAVPhotoCache.php b/lib/private/Repair/NC16/CleanupCardDAVPhotoCache.php index 39b48562791..25dc24fb66c 100644 --- a/lib/private/Repair/NC16/CleanupCardDAVPhotoCache.php +++ b/lib/private/Repair/NC16/CleanupCardDAVPhotoCache.php @@ -30,9 +30,9 @@ use OCP\Files\IAppData; use OCP\Files\NotFoundException; use OCP\Files\SimpleFS\ISimpleFolder; use OCP\IConfig; -use OCP\ILogger; use OCP\Migration\IOutput; use OCP\Migration\IRepairStep; +use Psr\Log\LoggerInterface; use RuntimeException; /** @@ -52,10 +52,9 @@ class CleanupCardDAVPhotoCache implements IRepairStep { /** @var IAppData */ private $appData; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; - public function __construct(IConfig $config, IAppData $appData, ILogger $logger) { + public function __construct(IConfig $config, IAppData $appData, LoggerInterface $logger) { $this->config = $config; $this->appData = $appData; $this->logger = $logger; @@ -71,7 +70,7 @@ class CleanupCardDAVPhotoCache implements IRepairStep { } catch (NotFoundException $e) { return; } catch (RuntimeException $e) { - $this->logger->logException($e, ['message' => 'Failed to fetch directory listing in CleanupCardDAVPhotoCache']); + $this->logger->error('Failed to fetch directory listing in CleanupCardDAVPhotoCache', ['exception' => $e]); return; } @@ -90,7 +89,7 @@ class CleanupCardDAVPhotoCache implements IRepairStep { /** @var ISimpleFolder $folder */ $folder->getFile('photo.')->delete(); } catch (\Exception $e) { - $this->logger->logException($e); + $this->logger->error($e->getMessage(), ['exception' => $e]); $output->warning('Could not delete file "dav-photocache/' . $folder->getName() . '/photo."'); } } diff --git a/lib/private/Repair/Owncloud/CleanPreviewsBackgroundJob.php b/lib/private/Repair/Owncloud/CleanPreviewsBackgroundJob.php index 67f9d6912d9..7f4bbc35c17 100644 --- a/lib/private/Repair/Owncloud/CleanPreviewsBackgroundJob.php +++ b/lib/private/Repair/Owncloud/CleanPreviewsBackgroundJob.php @@ -29,15 +29,14 @@ use OCP\Files\Folder; use OCP\Files\IRootFolder; use OCP\Files\NotFoundException; use OCP\Files\NotPermittedException; -use OCP\ILogger; use OCP\IUserManager; +use Psr\Log\LoggerInterface; class CleanPreviewsBackgroundJob extends QueuedJob { /** @var IRootFolder */ private $rootFolder; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; /** @var IJobList */ private $jobList; @@ -50,15 +49,9 @@ class CleanPreviewsBackgroundJob extends QueuedJob { /** * CleanPreviewsBackgroundJob constructor. - * - * @param IRootFolder $rootFolder - * @param ILogger $logger - * @param IJobList $jobList - * @param ITimeFactory $timeFactory - * @param IUserManager $userManager */ public function __construct(IRootFolder $rootFolder, - ILogger $logger, + LoggerInterface $logger, IJobList $jobList, ITimeFactory $timeFactory, IUserManager $userManager) { diff --git a/lib/private/Route/CachingRouter.php b/lib/private/Route/CachingRouter.php index 553ea285fd4..f65060e710b 100644 --- a/lib/private/Route/CachingRouter.php +++ b/lib/private/Route/CachingRouter.php @@ -24,7 +24,7 @@ */ namespace OC\Route; -use OCP\ILogger; +use Psr\Log\LoggerInterface; class CachingRouter extends Router { /** @@ -34,9 +34,8 @@ class CachingRouter extends Router { /** * @param \OCP\ICache $cache - * @param ILogger $logger */ - public function __construct($cache, ILogger $logger) { + public function __construct($cache, LoggerInterface $logger) { $this->cache = $cache; parent::__construct($logger); } diff --git a/lib/private/Route/Router.php b/lib/private/Route/Router.php index fcde8f08897..b957173cacc 100644 --- a/lib/private/Route/Router.php +++ b/lib/private/Route/Router.php @@ -34,9 +34,9 @@ namespace OC\Route; use OC\AppFramework\Routing\RouteParser; use OCP\AppFramework\App; -use OCP\ILogger; use OCP\Route\IRouter; use OCP\Util; +use Psr\Log\LoggerInterface; use Symfony\Component\Routing\Exception\ResourceNotFoundException; use Symfony\Component\Routing\Exception\RouteNotFoundException; use Symfony\Component\Routing\Generator\UrlGenerator; @@ -61,15 +61,11 @@ class Router implements IRouter { protected $loaded = false; /** @var array */ protected $loadedApps = []; - /** @var ILogger */ - protected $logger; + protected LoggerInterface $logger; /** @var RequestContext */ protected $context; - /** - * @param ILogger $logger - */ - public function __construct(ILogger $logger) { + public function __construct(LoggerInterface $logger) { $this->logger = $logger; $baseUrl = \OC::$WEBROOT; if (!(\OC::$server->getConfig()->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true')) { @@ -364,7 +360,7 @@ class Router implements IRouter { try { return $this->getGenerator()->generate($name, $parameters, $referenceType); } catch (RouteNotFoundException $e) { - $this->logger->logException($e, ['level' => ILogger::INFO]); + $this->logger->info($e->getMessage(), ['exception' => $e]); return ''; } } diff --git a/lib/private/Search/SearchComposer.php b/lib/private/Search/SearchComposer.php index d5f35f504e0..3c228261ec2 100644 --- a/lib/private/Search/SearchComposer.php +++ b/lib/private/Search/SearchComposer.php @@ -28,14 +28,14 @@ declare(strict_types=1); namespace OC\Search; use InvalidArgumentException; -use OC\AppFramework\Bootstrap\Coordinator; use OCP\AppFramework\QueryException; -use OCP\ILogger; use OCP\IServerContainer; use OCP\IUser; use OCP\Search\IProvider; use OCP\Search\ISearchQuery; use OCP\Search\SearchResult; +use OC\AppFramework\Bootstrap\Coordinator; +use Psr\Log\LoggerInterface; use function array_map; /** @@ -68,12 +68,11 @@ class SearchComposer { /** @var IServerContainer */ private $container; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; public function __construct(Coordinator $bootstrapCoordinator, IServerContainer $container, - ILogger $logger) { + LoggerInterface $logger) { $this->container = $container; $this->logger = $logger; $this->bootstrapCoordinator = $bootstrapCoordinator; @@ -99,9 +98,8 @@ class SearchComposer { $this->providers[$provider->getId()] = $provider; } catch (QueryException $e) { // Log an continue. We can be fault tolerant here. - $this->logger->logException($e, [ - 'message' => 'Could not load search provider dynamically: ' . $e->getMessage(), - 'level' => ILogger::ERROR, + $this->logger->error('Could not load search provider dynamically: ' . $e->getMessage(), [ + 'exception' => $e, 'app' => $registration->getAppId(), ]); } diff --git a/lib/private/Security/Bruteforce/Throttler.php b/lib/private/Security/Bruteforce/Throttler.php index abbe77c6637..c47d102b881 100644 --- a/lib/private/Security/Bruteforce/Throttler.php +++ b/lib/private/Security/Bruteforce/Throttler.php @@ -36,8 +36,8 @@ use OC\Security\Normalizer\IpAddress; use OCP\AppFramework\Utility\ITimeFactory; use OCP\IConfig; use OCP\IDBConnection; -use OCP\ILogger; use OCP\Security\Bruteforce\MaxDelayReached; +use Psr\Log\LoggerInterface; /** * Class Throttler implements the bruteforce protection for security actions in @@ -62,22 +62,15 @@ class Throttler { private $db; /** @var ITimeFactory */ private $timeFactory; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; /** @var IConfig */ private $config; /** @var bool */ private $hasAttemptsDeleted = false; - /** - * @param IDBConnection $db - * @param ITimeFactory $timeFactory - * @param ILogger $logger - * @param IConfig $config - */ public function __construct(IDBConnection $db, ITimeFactory $timeFactory, - ILogger $logger, + LoggerInterface $logger, IConfig $config) { $this->db = $db; $this->timeFactory = $timeFactory; diff --git a/lib/private/Security/CertificateManager.php b/lib/private/Security/CertificateManager.php index 74ea59c3792..fa26c19ceae 100644 --- a/lib/private/Security/CertificateManager.php +++ b/lib/private/Security/CertificateManager.php @@ -36,8 +36,8 @@ use OC\Files\Filesystem; use OCP\ICertificate; use OCP\ICertificateManager; use OCP\IConfig; -use OCP\ILogger; use OCP\Security\ISecureRandom; +use Psr\Log\LoggerInterface; /** * Manage trusted certificates for users @@ -53,25 +53,16 @@ class CertificateManager implements ICertificateManager { */ protected $config; - /** - * @var ILogger - */ - protected $logger; + protected LoggerInterface $logger; /** @var ISecureRandom */ protected $random; private ?string $bundlePath = null; - /** - * @param \OC\Files\View $view relative to data/ - * @param IConfig $config - * @param ILogger $logger - * @param ISecureRandom $random - */ public function __construct(\OC\Files\View $view, IConfig $config, - ILogger $logger, + LoggerInterface $logger, ISecureRandom $random) { $this->view = $view; $this->config = $config; @@ -147,7 +138,8 @@ class CertificateManager implements ICertificateManager { $defaultCertificates = file_get_contents(\OC::$SERVERROOT . '/resources/config/ca-bundle.crt'); if (strlen($defaultCertificates) < 1024) { // sanity check to verify that we have some content for our bundle // log as exception so we have a stacktrace - $this->logger->logException(new \Exception('Shipped ca-bundle is empty, refusing to create certificate bundle')); + $e = new \Exception('Shipped ca-bundle is empty, refusing to create certificate bundle'); + $this->logger->error($e->getMessage(), ['exception' => $e]); return; } diff --git a/lib/private/Security/IdentityProof/Manager.php b/lib/private/Security/IdentityProof/Manager.php index 0878efeebc7..c92d7390969 100644 --- a/lib/private/Security/IdentityProof/Manager.php +++ b/lib/private/Security/IdentityProof/Manager.php @@ -32,9 +32,9 @@ namespace OC\Security\IdentityProof; use OC\Files\AppData\Factory; use OCP\Files\IAppData; use OCP\IConfig; -use OCP\ILogger; use OCP\IUser; use OCP\Security\ICrypto; +use Psr\Log\LoggerInterface; class Manager { /** @var IAppData */ @@ -43,13 +43,12 @@ class Manager { private $crypto; /** @var IConfig */ private $config; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; public function __construct(Factory $appDataFactory, ICrypto $crypto, IConfig $config, - ILogger $logger + LoggerInterface $logger ) { $this->appData = $appDataFactory->get('identityproof'); $this->crypto = $crypto; diff --git a/lib/private/Server.php b/lib/private/Server.php index b189905cfaf..7d76715397a 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -2360,8 +2360,8 @@ class Server extends ServerContainer implements IServerContainer { private function registerDeprecatedAlias(string $alias, string $target) { $this->registerService($alias, function (ContainerInterface $container) use ($target, $alias) { try { - /** @var ILogger $logger */ - $logger = $container->get(ILogger::class); + /** @var LoggerInterface $logger */ + $logger = $container->get(LoggerInterface::class); $logger->debug('The requested alias "' . $alias . '" is deprecated. Please request "' . $target . '" directly. This alias will be removed in a future Nextcloud version.', ['app' => 'serverDI']); } catch (ContainerExceptionInterface $e) { // Could not get logger. Continue diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index 2aa4d099024..2a76ddafb25 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -57,7 +57,6 @@ use OCP\HintException; use OCP\IConfig; use OCP\IGroupManager; use OCP\IL10N; -use OCP\ILogger; use OCP\IURLGenerator; use OCP\IUser; use OCP\IUserManager; @@ -75,6 +74,7 @@ use OCP\Share\IManager; use OCP\Share\IProviderFactory; use OCP\Share\IShare; use OCP\Share\IShareProvider; +use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\GenericEvent; @@ -85,8 +85,7 @@ class Manager implements IManager { /** @var IProviderFactory */ private $factory; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; /** @var IConfig */ private $config; /** @var ISecureRandom */ @@ -125,7 +124,7 @@ class Manager implements IManager { private $knownUserService; public function __construct( - ILogger $logger, + LoggerInterface $logger, IConfig $config, ISecureRandom $secureRandom, IHasher $hasher, @@ -951,7 +950,7 @@ class Manager implements IManager { return; } } catch (\Exception $e) { - $this->logger->logException($e, ['message' => 'Share notification mail could not be sent']); + $this->logger->error('Share notification mail could not be sent', ['exception' => $e]); } } diff --git a/lib/private/Template/CSSResourceLocator.php b/lib/private/Template/CSSResourceLocator.php index 9ee11e723e5..a038ba7ce9b 100644 --- a/lib/private/Template/CSSResourceLocator.php +++ b/lib/private/Template/CSSResourceLocator.php @@ -31,7 +31,7 @@ */ namespace OC\Template; -use OCP\ILogger; +use Psr\Log\LoggerInterface; class CSSResourceLocator extends ResourceLocator { @@ -39,13 +39,12 @@ class CSSResourceLocator extends ResourceLocator { protected $scssCacher; /** - * @param ILogger $logger * @param string $theme * @param array $core_map * @param array $party_map * @param SCSSCacher $scssCacher */ - public function __construct(ILogger $logger, $theme, $core_map, $party_map, $scssCacher) { + public function __construct(LoggerInterface $logger, $theme, $core_map, $party_map, $scssCacher) { $this->scssCacher = $scssCacher; parent::__construct($logger, $theme, $core_map, $party_map); diff --git a/lib/private/Template/IconsCacher.php b/lib/private/Template/IconsCacher.php index 01500aa2e9c..01a6b714703 100644 --- a/lib/private/Template/IconsCacher.php +++ b/lib/private/Template/IconsCacher.php @@ -36,13 +36,12 @@ use OCP\Files\IAppData; use OCP\Files\NotFoundException; use OCP\Files\SimpleFS\ISimpleFile; use OCP\Files\SimpleFS\ISimpleFolder; -use OCP\ILogger; use OCP\IURLGenerator; +use Psr\Log\LoggerInterface; class IconsCacher { - /** @var ILogger */ - protected $logger; + protected LoggerInterface $logger; /** @var IAppData */ protected $appData; @@ -68,13 +67,9 @@ class IconsCacher { private $cachedList; /** - * @param ILogger $logger - * @param Factory $appDataFactory - * @param IURLGenerator $urlGenerator - * @param ITimeFactory $timeFactory * @throws \OCP\Files\NotPermittedException */ - public function __construct(ILogger $logger, + public function __construct(LoggerInterface $logger, Factory $appDataFactory, IURLGenerator $urlGenerator, ITimeFactory $timeFactory) { diff --git a/lib/private/Template/JSCombiner.php b/lib/private/Template/JSCombiner.php index d2073fbbb83..a6d9f0ee558 100644 --- a/lib/private/Template/JSCombiner.php +++ b/lib/private/Template/JSCombiner.php @@ -33,8 +33,8 @@ use OCP\Files\NotPermittedException; use OCP\Files\SimpleFS\ISimpleFolder; use OCP\ICache; use OCP\ICacheFactory; -use OCP\ILogger; use OCP\IURLGenerator; +use Psr\Log\LoggerInterface; class JSCombiner { @@ -50,24 +50,16 @@ class JSCombiner { /** @var SystemConfig */ protected $config; - /** @var ILogger */ - protected $logger; + protected LoggerInterface $logger; /** @var ICacheFactory */ private $cacheFactory; - /** - * @param IAppData $appData - * @param IURLGenerator $urlGenerator - * @param ICacheFactory $cacheFactory - * @param SystemConfig $config - * @param ILogger $logger - */ public function __construct(IAppData $appData, IURLGenerator $urlGenerator, ICacheFactory $cacheFactory, SystemConfig $config, - ILogger $logger) { + LoggerInterface $logger) { $this->appData = $appData; $this->urlGenerator = $urlGenerator; $this->cacheFactory = $cacheFactory; diff --git a/lib/private/Template/JSResourceLocator.php b/lib/private/Template/JSResourceLocator.php index bf84e1ae958..95ae0d3d832 100644 --- a/lib/private/Template/JSResourceLocator.php +++ b/lib/private/Template/JSResourceLocator.php @@ -27,12 +27,14 @@ */ namespace OC\Template; +use Psr\Log\LoggerInterface; + class JSResourceLocator extends ResourceLocator { /** @var JSCombiner */ protected $jsCombiner; - public function __construct(\OCP\ILogger $logger, $theme, array $core_map, array $party_map, JSCombiner $JSCombiner) { + public function __construct(LoggerInterface $logger, $theme, array $core_map, array $party_map, JSCombiner $JSCombiner) { parent::__construct($logger, $theme, $core_map, $party_map); $this->jsCombiner = $JSCombiner; diff --git a/lib/private/Template/ResourceLocator.php b/lib/private/Template/ResourceLocator.php index 3ca34259907..5a50cc6fd1b 100755 --- a/lib/private/Template/ResourceLocator.php +++ b/lib/private/Template/ResourceLocator.php @@ -29,6 +29,8 @@ */ namespace OC\Template; +use Psr\Log\LoggerInterface; + abstract class ResourceLocator { protected $theme; @@ -39,16 +41,14 @@ abstract class ResourceLocator { protected $resources = []; - /** @var \OCP\ILogger */ - protected $logger; + protected LoggerInterface $logger; /** - * @param \OCP\ILogger $logger * @param string $theme * @param array $core_map * @param array $party_map */ - public function __construct(\OCP\ILogger $logger, $theme, $core_map, $party_map) { + public function __construct(LoggerInterface $logger, $theme, $core_map, $party_map) { $this->logger = $logger; $this->theme = $theme; $this->mapping = $core_map + $party_map; diff --git a/lib/private/Template/SCSSCacher.php b/lib/private/Template/SCSSCacher.php index 536557e7a3d..8b691cdb213 100644 --- a/lib/private/Template/SCSSCacher.php +++ b/lib/private/Template/SCSSCacher.php @@ -41,16 +41,15 @@ use OCP\Files\SimpleFS\ISimpleFolder; use OCP\ICache; use OCP\ICacheFactory; use OCP\IConfig; -use OCP\ILogger; use OCP\IMemcache; use OCP\IURLGenerator; +use Psr\Log\LoggerInterface; use ScssPhp\ScssPhp\Compiler; use ScssPhp\ScssPhp\OutputStyle; class SCSSCacher { - /** @var ILogger */ - protected $logger; + protected LoggerInterface $logger; /** @var IAppData */ protected $appData; @@ -91,17 +90,9 @@ class SCSSCacher { private $appConfig; /** - * @param ILogger $logger - * @param Factory $appDataFactory - * @param IURLGenerator $urlGenerator - * @param IConfig $config - * @param \OC_Defaults $defaults * @param string $serverRoot - * @param ICacheFactory $cacheFactory - * @param IconsCacher $iconsCacher - * @param ITimeFactory $timeFactory */ - public function __construct(ILogger $logger, + public function __construct(LoggerInterface $logger, Factory $appDataFactory, IURLGenerator $urlGenerator, IConfig $config, @@ -340,7 +331,7 @@ class SCSSCacher { '@import "functions.scss";' . '@import "' . $fileNameSCSS . '";'); } catch (\Exception $e) { - $this->logger->logException($e, ['app' => 'scss_cacher']); + $this->logger->error($e->getMessage(), ['app' => 'scss_cacher', 'exception' => $e]); return false; } @@ -395,7 +386,7 @@ class SCSSCacher { try { $file->delete(); } catch (NotPermittedException $e) { - $this->logger->logException($e, ['message' => 'SCSSCacher::resetCache unable to delete file: ' . $file->getName(), 'app' => 'scss_cacher']); + $this->logger->error('SCSSCacher::resetCache unable to delete file: ' . $file->getName(), ['exception' => $e, 'app' => 'scss_cacher']); } } } @@ -431,7 +422,7 @@ class SCSSCacher { $scss->compile($variables); $this->injectedVariables = $variables; } catch (\Exception $e) { - $this->logger->logException($e, ['app' => 'scss_cacher']); + $this->logger->error($e->getMessage(), ['exception' => $e, 'app' => 'scss_cacher']); } return $variables; diff --git a/lib/private/Updater/ChangesCheck.php b/lib/private/Updater/ChangesCheck.php index e3ced6e5b12..e2b66853788 100644 --- a/lib/private/Updater/ChangesCheck.php +++ b/lib/private/Updater/ChangesCheck.php @@ -30,21 +30,20 @@ namespace OC\Updater; use OCP\AppFramework\Db\DoesNotExistException; use OCP\Http\Client\IClientService; use OCP\Http\Client\IResponse; -use OCP\ILogger; +use Psr\Log\LoggerInterface; class ChangesCheck { /** @var IClientService */ protected $clientService; /** @var ChangesMapper */ private $mapper; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; public const RESPONSE_NO_CONTENT = 0; public const RESPONSE_USE_CACHE = 1; public const RESPONSE_HAS_CONTENT = 2; - public function __construct(IClientService $clientService, ChangesMapper $mapper, ILogger $logger) { + public function __construct(IClientService $clientService, ChangesMapper $mapper, LoggerInterface $logger) { $this->clientService = $clientService; $this->mapper = $mapper; $this->logger = $logger; diff --git a/lib/private/User/Session.php b/lib/private/User/Session.php index cd26337cd20..365a01c4595 100644 --- a/lib/private/User/Session.php +++ b/lib/private/User/Session.php @@ -54,7 +54,6 @@ use OCP\AppFramework\Utility\ITimeFactory; use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\NotPermittedException; use OCP\IConfig; -use OCP\ILogger; use OCP\IRequest; use OCP\ISession; use OCP\IUser; @@ -64,6 +63,7 @@ use OCP\Security\ISecureRandom; use OCP\Session\Exceptions\SessionNotAvailableException; use OCP\User\Events\PostLoginEvent; use OCP\Util; +use Psr\Log\LoggerInterface; use Symfony\Component\EventDispatcher\GenericEvent; /** @@ -114,21 +114,10 @@ class Session implements IUserSession, Emitter { /** @var ILockdownManager */ private $lockdownManager; - /** @var ILogger */ - private $logger; + private LoggerInterface $logger; /** @var IEventDispatcher */ private $dispatcher; - /** - * @param Manager $manager - * @param ISession $session - * @param ITimeFactory $timeFactory - * @param IProvider|null $tokenProvider - * @param IConfig $config - * @param ISecureRandom $random - * @param ILockdownManager $lockdownManager - * @param ILogger $logger - */ public function __construct(Manager $manager, ISession $session, ITimeFactory $timeFactory, @@ -136,7 +125,7 @@ class Session implements IUserSession, Emitter { IConfig $config, ISecureRandom $random, ILockdownManager $lockdownManager, - ILogger $logger, + LoggerInterface $logger, IEventDispatcher $dispatcher ) { $this->manager = $manager; @@ -533,9 +522,8 @@ class Session implements IUserSession, Emitter { } catch (ExpiredTokenException $e) { throw $e; } catch (InvalidTokenException $ex) { - $this->logger->logException($ex, [ - 'level' => ILogger::DEBUG, - 'message' => 'Token is not valid: ' . $ex->getMessage(), + $this->logger->debug('Token is not valid: ' . $ex->getMessage(), [ + 'exception' => $ex, ]); return false; } @@ -890,7 +878,7 @@ class Session implements IUserSession, Emitter { } catch (SessionNotAvailableException $ex) { return false; } catch (InvalidTokenException $ex) { - \OC::$server->getLogger()->warning('Renewing session token failed', ['app' => 'core']); + $this->logger->warning('Renewing session token failed', ['app' => 'core']); return false; } |