diff --git a/src/Connection.php b/src/Connection.php index 6d619e1..6b01479 100644 --- a/src/Connection.php +++ b/src/Connection.php @@ -116,6 +116,11 @@ abstract class Connection $this->stream->close(); $this->stream = new NullStream(); + + $this->logger->debug('{class} disconnected from {address}', [ + 'class' => static::class, + 'address' => $this->address, + ]); } protected function handleError(Frame\Error $error): void diff --git a/src/Consumer.php b/src/Consumer.php index 3aa93a8..81a58ff 100644 --- a/src/Consumer.php +++ b/src/Consumer.php @@ -69,6 +69,12 @@ final class Consumer extends Connection return call(function (): \Generator { yield parent::connect(); + $this->logger->debug('Consumer {topic}:{channel} connected to {host}', [ + 'topic' => $this->topic, + 'channel' => $this->channel, + 'host' => $this->address, + ]); + $this->run(); }); } diff --git a/src/Producer.php b/src/Producer.php index 722a2eb..2e1b0a9 100644 --- a/src/Producer.php +++ b/src/Producer.php @@ -15,6 +15,20 @@ use function Amp\call; final class Producer extends Connection { + + public function __construct( + private string $address, + private ClientConfig $clientConfig, + private LoggerInterface $logger, + ) + { + parent::__construct( + $this->address, + $this->clientConfig, + $this->logger, + ); + } + public static function create( string $address, ClientConfig $clientConfig = null, @@ -37,6 +51,10 @@ final class Producer extends Connection return call(function (): \Generator { yield parent::connect(); + $this->logger->debug('Producer connected to {host}', [ + 'host' => $this->address, + ]); + $this->run(); }); }