diff options
Diffstat (limited to 'apps/workflowengine')
-rw-r--r-- | apps/workflowengine/lib/Entity/File.php | 5 | ||||
-rw-r--r-- | apps/workflowengine/lib/Manager.php | 64 | ||||
-rw-r--r-- | apps/workflowengine/lib/Service/Logger.php | 21 | ||||
-rw-r--r-- | apps/workflowengine/tests/ManagerTest.php | 7 |
4 files changed, 22 insertions, 75 deletions
diff --git a/apps/workflowengine/lib/Entity/File.php b/apps/workflowengine/lib/Entity/File.php index 3f09fcd24a1..5a2549b1f65 100644 --- a/apps/workflowengine/lib/Entity/File.php +++ b/apps/workflowengine/lib/Entity/File.php @@ -33,7 +33,6 @@ use OCP\Files\IRootFolder; use OCP\Files\Node; use OCP\Files\NotFoundException; use OCP\IL10N; -use OCP\ILogger; use OCP\IURLGenerator; use OCP\IUser; use OCP\IUserManager; @@ -59,8 +58,6 @@ class File implements IEntity, IDisplayText, IUrl, IIcon, IContextPortation { protected $urlGenerator; /** @var IRootFolder */ protected $root; - /** @var ILogger */ - protected $logger; /** @var string */ protected $eventName; /** @var Event */ @@ -82,7 +79,6 @@ class File implements IEntity, IDisplayText, IUrl, IIcon, IContextPortation { IL10N $l10n, IURLGenerator $urlGenerator, IRootFolder $root, - ILogger $logger, ShareManager $shareManager, IUserSession $userSession, ISystemTagManager $tagManager, @@ -91,7 +87,6 @@ class File implements IEntity, IDisplayText, IUrl, IIcon, IContextPortation { $this->l10n = $l10n; $this->urlGenerator = $urlGenerator; $this->root = $root; - $this->logger = $logger; $this->shareManager = $shareManager; $this->userSession = $userSession; $this->tagManager = $tagManager; diff --git a/apps/workflowengine/lib/Manager.php b/apps/workflowengine/lib/Manager.php index 7d55cff446e..28bc4417bb9 100644 --- a/apps/workflowengine/lib/Manager.php +++ b/apps/workflowengine/lib/Manager.php @@ -48,12 +48,10 @@ use OCA\WorkflowEngine\Service\RuleMatcher; use OCP\AppFramework\QueryException; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\EventDispatcher\IEventDispatcher; -use OCP\Files\Storage\IStorage; use OCP\ICacheFactory; use OCP\IConfig; use OCP\IDBConnection; use OCP\IL10N; -use OCP\ILogger; use OCP\IServerContainer; use OCP\IUserSession; use OCP\WorkflowEngine\Events\RegisterChecksEvent; @@ -66,32 +64,15 @@ use OCP\WorkflowEngine\IEntityEvent; use OCP\WorkflowEngine\IManager; use OCP\WorkflowEngine\IOperation; use OCP\WorkflowEngine\IRuleMatcher; +use Psr\Log\LoggerInterface; class Manager implements IManager { - /** @var IStorage */ - protected $storage; - - /** @var string */ - protected $path; - - /** @var object */ - protected $entity; - /** @var array[] */ protected $operations = []; /** @var array[] */ protected $checks = []; - /** @var IDBConnection */ - protected $connection; - - /** @var IServerContainer|\OC\Server */ - protected $container; - - /** @var IL10N */ - protected $l; - /** @var IEntity[] */ protected $registeredEntities = []; @@ -101,41 +82,20 @@ class Manager implements IManager { /** @var ICheck[] */ protected $registeredChecks = []; - /** @var ILogger */ - protected $logger; - /** @var CappedMemoryCache<int[]> */ protected CappedMemoryCache $operationsByScope; - /** @var IUserSession */ - protected $session; - - /** @var IEventDispatcher */ - private $dispatcher; - - /** @var IConfig */ - private $config; - private ICacheFactory $cacheFactory; - public function __construct( - IDBConnection $connection, - IServerContainer $container, - IL10N $l, - ILogger $logger, - IUserSession $session, - IEventDispatcher $dispatcher, - IConfig $config, - ICacheFactory $cacheFactory, + protected IDBConnection $connection, + protected IServerContainer $container, + protected IL10N $l, + protected LoggerInterface $logger, + protected IUserSession $session, + private IEventDispatcher $dispatcher, + private IConfig $config, + private ICacheFactory $cacheFactory, ) { - $this->connection = $connection; - $this->container = $container; - $this->l = $l; - $this->logger = $logger; $this->operationsByScope = new CappedMemoryCache(64); - $this->session = $session; - $this->dispatcher = $dispatcher; - $this->config = $config; - $this->cacheFactory = $cacheFactory; } public function getRuleMatcher(): IRuleMatcher { @@ -730,7 +690,7 @@ class Manager implements IManager { File::class => $this->container->query(File::class), ]; } catch (QueryException $e) { - $this->logger->logException($e); + $this->logger->error($e->getMessage(), ['exception' => $e]); return []; } } @@ -744,7 +704,7 @@ class Manager implements IManager { // None yet ]; } catch (QueryException $e) { - $this->logger->logException($e); + $this->logger->error($e->getMessage(), ['exception' => $e]); return []; } } @@ -766,7 +726,7 @@ class Manager implements IManager { $this->container->query(UserGroupMembership::class), ]; } catch (QueryException $e) { - $this->logger->logException($e); + $this->logger->error($e->getMessage(), ['exception' => $e]); return []; } } diff --git a/apps/workflowengine/lib/Service/Logger.php b/apps/workflowengine/lib/Service/Logger.php index 6ad7f8c4847..642b5973264 100644 --- a/apps/workflowengine/lib/Service/Logger.php +++ b/apps/workflowengine/lib/Service/Logger.php @@ -36,24 +36,17 @@ use OCP\Log\ILogFactory; use Psr\Log\LoggerInterface; class Logger { - /** @var ILogger */ - protected $generalLogger; - /** @var LoggerInterface */ - protected $flowLogger; - /** @var IConfig */ - private $config; - /** @var ILogFactory */ - private $logFactory; - - public function __construct(ILogger $generalLogger, IConfig $config, ILogFactory $logFactory) { - $this->generalLogger = $generalLogger; - $this->config = $config; - $this->logFactory = $logFactory; + protected ?LoggerInterface $flowLogger = null; + public function __construct( + protected LoggerInterface $generalLogger, + private IConfig $config, + private ILogFactory $logFactory, + ) { $this->initLogger(); } - protected function initLogger() { + protected function initLogger(): void { $default = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/flow.log'; $logFile = trim((string)$this->config->getAppValue(Application::APP_ID, 'logfile', $default)); if ($logFile !== '') { diff --git a/apps/workflowengine/tests/ManagerTest.php b/apps/workflowengine/tests/ManagerTest.php index 213daf49415..fd95f024acd 100644 --- a/apps/workflowengine/tests/ManagerTest.php +++ b/apps/workflowengine/tests/ManagerTest.php @@ -39,7 +39,6 @@ use OCP\ICacheFactory; use OCP\IConfig; use OCP\IDBConnection; use OCP\IL10N; -use OCP\ILogger; use OCP\IServerContainer; use OCP\IURLGenerator; use OCP\IUserManager; @@ -52,6 +51,7 @@ use OCP\WorkflowEngine\IEntityEvent; use OCP\WorkflowEngine\IManager; use OCP\WorkflowEngine\IOperation; use PHPUnit\Framework\MockObject\MockObject; +use Psr\Log\LoggerInterface; use Test\TestCase; /** @@ -65,7 +65,7 @@ class ManagerTest extends TestCase { protected $manager; /** @var MockObject|IDBConnection */ protected $db; - /** @var \PHPUnit\Framework\MockObject\MockObject|ILogger */ + /** @var \PHPUnit\Framework\MockObject\MockObject|LoggerInterface */ protected $logger; /** @var MockObject|IServerContainer */ protected $container; @@ -92,7 +92,7 @@ class ManagerTest extends TestCase { return vsprintf($text, $parameters); }); - $this->logger = $this->createMock(ILogger::class); + $this->logger = $this->createMock(LoggerInterface::class); $this->session = $this->createMock(IUserSession::class); $this->dispatcher = $this->createMock(IEventDispatcher::class); $this->config = $this->createMock(IConfig::class); @@ -403,7 +403,6 @@ class ManagerTest extends TestCase { $this->l, $this->createMock(IURLGenerator::class), $this->createMock(IRootFolder::class), - $this->createMock(ILogger::class), $this->createMock(\OCP\Share\IManager::class), $this->createMock(IUserSession::class), $this->createMock(ISystemTagManager::class), |