Merge pull request #23291 from nextcloud/techdebt/noid/use-psr-logger-in-event-dispatcher

Use PSR Logger in event dispatcher
This commit is contained in:
Roeland Jago Douma 2020-10-08 19:43:03 +02:00 committed by GitHub
commit b2dedbcc13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 10 deletions

View File

@ -35,6 +35,7 @@ use OCP\ILogger;
use OCP\IUser;
use OCP\IUserManager;
use OCP\IUserSession;
use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class RootCollectionTest extends \Test\TestCase {
@ -77,7 +78,7 @@ class RootCollectionTest extends \Test\TestCase {
new EventDispatcher(
new \Symfony\Component\EventDispatcher\EventDispatcher(),
\OC::$server,
$this->logger
$this->createMock(LoggerInterface::class)
),
$this->logger
);

View File

@ -28,6 +28,7 @@ declare(strict_types=1);
namespace OC\EventDispatcher;
use Psr\Log\LoggerInterface;
use function get_class;
use OC\Broadcast\Events\BroadcastEvent;
use OCP\Broadcast\Events\IBroadcastEvent;
@ -35,7 +36,6 @@ use OCP\EventDispatcher\ABroadcastedEvent;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IContainer;
use OCP\ILogger;
use OCP\IServerContainer;
use Symfony\Component\EventDispatcher\EventDispatcher as SymfonyDispatcher;
@ -47,12 +47,12 @@ class EventDispatcher implements IEventDispatcher {
/** @var IContainer */
private $container;
/** @var ILogger */
/** @var LoggerInterface */
private $logger;
public function __construct(SymfonyDispatcher $dispatcher,
IServerContainer $container,
ILogger $logger) {
LoggerInterface $logger) {
$this->dispatcher = $dispatcher;
$this->container = $container;
$this->logger = $logger;

View File

@ -30,7 +30,7 @@ use OCP\AppFramework\QueryException;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\IContainer;
use OCP\ILogger;
use Psr\Log\LoggerInterface;
/**
* Lazy service event listener
@ -46,7 +46,7 @@ final class ServiceEventListener {
/** @var string */
private $class;
/** @var ILogger */
/** @var LoggerInterface */
private $logger;
/** @var null|IEventListener */
@ -54,7 +54,7 @@ final class ServiceEventListener {
public function __construct(IContainer $container,
string $class,
ILogger $logger) {
LoggerInterface $logger) {
$this->container = $container;
$this->class = $class;
$this->logger = $logger;
@ -65,9 +65,8 @@ final class ServiceEventListener {
try {
$this->service = $this->container->query($this->class);
} catch (QueryException $e) {
$this->logger->logException($e, [
'level' => ILogger::ERROR,
'message' => "Could not load event listener service " . $this->class,
$this->logger->error("Could not load event listener service " . $this->class, [
'exception' => $e,
]);
return;
}