1+ import logging
12import uuid
23from typing import Any , Optional
34
2425from .exceptions import ValidationCodeException
2526from .options import ReceiverOption , SenderOption
2627
28+ logger = logging .getLogger (__name__ )
29+
2730
2831class Management :
2932 def __init__ (self , conn : BlockingConnection ):
@@ -33,10 +36,12 @@ def __init__(self, conn: BlockingConnection):
3336
3437 def open (self ) -> None :
3538 if self ._sender is None :
39+ logger .debug ("Creating Sender" )
3640 self ._sender = self ._create_sender (
3741 CommonValues .management_node_address .value
3842 )
3943 if self ._receiver is None :
44+ logger .debug ("Creating Receiver" )
4045 self ._receiver = self ._create_receiver (
4146 CommonValues .management_node_address .value ,
4247 )
@@ -49,6 +54,7 @@ def _create_receiver(self, addr: str) -> BlockingReceiver:
4954
5055 # closes the connection to the AMQP 1.0 server.
5156 def close (self ) -> None :
57+ logger .debug ("Closing Sender and Receiver" )
5258 if self ._sender is not None :
5359 self ._sender .close ()
5460 if self ._receiver is not None :
@@ -80,16 +86,19 @@ def _request(
8086 )
8187
8288 if self ._sender is not None :
89+ logger .debug ("Sending message: " + str (amq_message ))
8390 self ._sender .send (amq_message )
8491
8592 if self ._receiver is not None :
8693 msg = self ._receiver .receive ()
94+ logger .debug ("Received message: " + str (msg ))
8795
8896 self ._validate_reponse_code (int (msg .subject ), expected_response_codes )
8997
9098 def declare_exchange (
9199 self , exchange_specification : ExchangeSpecification
92100 ) -> ExchangeSpecification :
101+ logger .debug ("delete_exchange operation called" )
93102 body = {}
94103 body ["auto_delete" ] = exchange_specification .is_auto_delete
95104 body ["durable" ] = exchange_specification .is_durable
@@ -115,6 +124,7 @@ def declare_exchange(
115124 def declare_queue (
116125 self , queue_specification : QueueSpecification
117126 ) -> QueueSpecification :
127+ logger .debug ("declare_queue operation called" )
118128 body = {}
119129 body ["auto_delete" ] = queue_specification .is_auto_delete
120130 body ["durable" ] = queue_specification .is_durable
@@ -141,6 +151,7 @@ def declare_queue(
141151 return queue_specification
142152
143153 def delete_exchange (self , exchange_name : str ) -> None :
154+ logger .debug ("delete_exchange operation called" )
144155 path = exchange_address (exchange_name )
145156
146157 print (path )
@@ -155,6 +166,7 @@ def delete_exchange(self, exchange_name: str) -> None:
155166 )
156167
157168 def delete_queue (self , queue_name : str ) -> None :
169+ logger .debug ("delete_queue operation called" )
158170 path = queue_address (queue_name )
159171
160172 self .request (
@@ -169,7 +181,7 @@ def delete_queue(self, queue_name: str) -> None:
169181 def _validate_reponse_code (
170182 self , response_code : int , expected_response_codes : list [int ]
171183 ) -> None :
172- print ("response_code received: " + str (response_code ))
184+ logger . debug ("response_code received: " + str (response_code ))
173185 if response_code == CommonValues .response_code_409 .value :
174186 # TODO replace with a new defined Exception
175187 raise ValidationCodeException ("ErrPreconditionFailed" )
@@ -184,6 +196,7 @@ def _validate_reponse_code(
184196
185197 # TODO
186198 def bind (self , bind_specification : BindingSpecification ) -> str :
199+ logger .debug ("Bind Operation called" )
187200 body = {}
188201 body ["binding_key" ] = bind_specification .binding_key
189202 body ["source" ] = bind_specification .source_exchange
@@ -206,6 +219,7 @@ def bind(self, bind_specification: BindingSpecification) -> str:
206219
207220 # TODO
208221 def unbind (self , binding_exchange_queue_path : str ) -> None :
222+ logger .debug ("UnBind Operation called" )
209223 self .request (
210224 None ,
211225 binding_exchange_queue_path ,
0 commit comments