Add some logs

This commit is contained in:
2021-09-13 23:49:15 +03:00
parent 7984d09e83
commit 56cdda1a0d
3 changed files with 29 additions and 0 deletions

View File

@ -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

View File

@ -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();
});
}

View File

@ -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();
});
}