Use PSR Logger in event dispatcher
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
e10cad4a71
commit
51fbcb0801
|
@ -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
|
||||
);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue