1 | <?php |
||
15 | final class Logger implements ConnectionInterface |
||
16 | { |
||
17 | private $connection; |
||
18 | private $logger; |
||
19 | |||
20 | 12 | public function __construct( |
|
21 | ConnectionInterface $connection, |
||
22 | LoggerInterface $logger |
||
23 | ) { |
||
24 | 12 | $this->connection = $connection; |
|
25 | 12 | $this->logger = $logger; |
|
26 | 12 | } |
|
27 | |||
28 | 2 | public function protocol(): Protocol |
|
29 | { |
||
30 | 2 | return $this->connection->protocol(); |
|
31 | } |
||
32 | |||
33 | /** |
||
34 | * {@inheritdoc} |
||
35 | */ |
||
36 | 2 | public function send(Frame $frame): ConnectionInterface |
|
37 | { |
||
38 | 2 | $this->logger->debug( |
|
39 | 2 | 'AMQP frame about to be sent', |
|
40 | [ |
||
41 | 2 | 'type' => $frame->type()->toInt(), |
|
42 | 2 | 'channel' => $frame->channel()->toInt(), |
|
43 | 2 | 'uuid' => $uuid = (string) Uuid::uuid4(), |
|
44 | ] |
||
45 | ); |
||
46 | |||
47 | 2 | $this->connection->send($frame); |
|
48 | 2 | $this->logger->debug('AMQP frame sent', ['uuid' => $uuid]); |
|
49 | |||
50 | 2 | return $this; |
|
51 | } |
||
52 | |||
53 | /** |
||
54 | * {@inheritdoc} |
||
55 | */ |
||
56 | 2 | public function wait(string ...$names): Frame |
|
57 | { |
||
58 | 2 | $this->logger->debug('Waiting for AMQP frame', ['names' => $names]); |
|
59 | 2 | $frame = $this->connection->wait(...$names); |
|
60 | 2 | $this->logger->debug( |
|
61 | 2 | 'AMQP frame received', |
|
62 | [ |
||
63 | 2 | 'type' => $frame->type()->toInt(), |
|
64 | 2 | 'channel' => $frame->channel()->toInt(), |
|
65 | ] |
||
66 | ); |
||
67 | |||
68 | 2 | return $frame; |
|
69 | } |
||
70 | |||
71 | public function maxFrameSize(): MaxFrameSize |
||
75 | |||
76 | 2 | public function close(): void |
|
81 | |||
82 | 2 | public function closed(): bool |
|
86 | } |
||
87 |