# Path: coolamqp/framing/frames.py
# class AMQPMethodFrame(AMQPFrame):
#     FRAME_TYPE = FRAME_METHOD
#     __slots__ = ('payload', )
# 
#     def __init__(self, channel, payload):
#         # type: (int, coolamqp.framing.base.AMQPMethodPayload) -> None
#         """
#         :param channel: channel ID
#         :param payload: AMQPMethodPayload instance
#         """
#         AMQPFrame.__init__(self, channel)
#         self.payload = payload
# 
#     def __str__(self):  # type: () -> str
#         return 'AMQPMethodFrame(%s, %s)' % (self.channel, self.payload)
# 
#     def write_to(self, buf):
#         if self.payload.IS_CONTENT_STATIC:
#             buf.write(STRUCT_BH.pack(FRAME_METHOD, self.channel))
#             buf.write(self.payload.STATIC_CONTENT)
#         else:
#             buf.write(STRUCT_BHL.pack(FRAME_METHOD, self.channel,
#                                       4 + self.payload.get_size()))
#             buf.write(self.payload.BINARY_HEADER)
#             self.payload.write_arguments(buf)
#             buf.write(FRAME_END_BYTE)
# 
#     @classmethod
#     def unserialize(cls, channel, payload_as_buffer):
#         clsmet = STRUCT_HH.unpack_from(payload_as_buffer, 0)
# 
#         try:
#             method_payload_class = IDENT_TO_METHOD[clsmet]
#             payload = method_payload_class.from_buffer(payload_as_buffer, 4)
#         except KeyError:
#             raise ValueError('Invalid class %s method %s' % clsmet)
#         else:
#             return cls(channel, payload)
# 
#     def get_size(self):  # type: () -> int
#         # frame_header = (method(1) + channel(2) + length(4) + class(2) + method(2) + payload(N) + frame_end(1))
#         return 12 + self.payload.get_size()


import logging
from coolamqp.framing.frames import AMQPMethodFrame
        """
        Called by AMQP upon receiving a frame information

        :param timestamp: timestamp
        :type timestamp: float
        :param frame: frame that is sent or received
        :type frame: :class:`coolamqp.framing.base.AMQPFrame`
        :param direction: either 'to_client' or 'to_server'
        :type direction: str
        """


class LoggingFrameTracer(BaseFrameTracer):
    """
    A frame tracer that outputs each frame to log

    :param logger: the logger to log onto
    :param log_level: the level of logging to log with
    """
    def __init__(self, logger, log_level=logging.WARNING):
        self.logger = logger
        self.log_level = log_level

    def on_frame(self, timestamp, frame, direction):
        if direction == 'to_client':
            if isinstance(frame, AMQPMethodFrame):
                self.logger.log(self.log_level, 'RECEIVED METHOD %s', frame.payload)
            else:
                self.logger.log(self.log_level, 'RECEIVED %s type %s', frame, type(frame))
        else:

# Path: coolamqp/framing/frames.py
# class AMQPMethodFrame(AMQPFrame):
#     FRAME_TYPE = FRAME_METHOD
#     __slots__ = ('payload', )
# 
#     def __init__(self, channel, payload):
#         # type: (int, coolamqp.framing.base.AMQPMethodPayload) -> None
#         """
#         :param channel: channel ID
#         :param payload: AMQPMethodPayload instance
#         """
#         AMQPFrame.__init__(self, channel)
#         self.payload = payload
# 
#     def __str__(self):  # type: () -> str
#         return 'AMQPMethodFrame(%s, %s)' % (self.channel, self.payload)
# 
#     def write_to(self, buf):
#         if self.payload.IS_CONTENT_STATIC:
#             buf.write(STRUCT_BH.pack(FRAME_METHOD, self.channel))
#             buf.write(self.payload.STATIC_CONTENT)
#         else:
#             buf.write(STRUCT_BHL.pack(FRAME_METHOD, self.channel,
#                                       4 + self.payload.get_size()))
#             buf.write(self.payload.BINARY_HEADER)
#             self.payload.write_arguments(buf)
#             buf.write(FRAME_END_BYTE)
# 
#     @classmethod
#     def unserialize(cls, channel, payload_as_buffer):
#         clsmet = STRUCT_HH.unpack_from(payload_as_buffer, 0)
# 
#         try:
#             method_payload_class = IDENT_TO_METHOD[clsmet]
#             payload = method_payload_class.from_buffer(payload_as_buffer, 4)
#         except KeyError:
#             raise ValueError('Invalid class %s method %s' % clsmet)
#         else:
#             return cls(channel, payload)
# 
#     def get_size(self):  # type: () -> int
#         # frame_header = (method(1) + channel(2) + length(4) + class(2) + method(2) + payload(N) + frame_end(1))
#         return 12 + self.payload.get_size()


# Path: coolamqp/tracing.py
import logging
from coolamqp.framing.frames import AMQPMethodFrame

        """
        Called by AMQP upon receiving a frame information

        :param timestamp: timestamp
        :type timestamp: float
        :param frame: frame that is sent or received
        :type frame: :class:`coolamqp.framing.base.AMQPFrame`
        :param direction: either 'to_client' or 'to_server'
        :type direction: str
        """


class LoggingFrameTracer(BaseFrameTracer):
    """
    A frame tracer that outputs each frame to log

    :param logger: the logger to log onto
    :param log_level: the level of logging to log with
    """
    def __init__(self, logger, log_level=logging.WARNING):
        self.logger = logger
        self.log_level = log_level

    def on_frame(self, timestamp, frame, direction):
        if direction == 'to_client':
            if isinstance(frame, AMQPMethodFrame):
                self.logger.log(self.log_level, 'RECEIVED METHOD %s', frame.payload)
            else:
                self.logger.log(self.log_level, 'RECEIVED %s type %s', frame, type(frame))
        else:

            if isinstance(frame, AMQPMethodFrame):