Commit 58c82e3b authored by Grégory Wisniewski's avatar Grégory Wisniewski

Add a packet logger for custom and fine-grained debugging messages.


git-svn-id: https://svn.erp5.org/repos/neo/trunk@1297 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent dff0efea
......@@ -288,7 +288,7 @@ class Connection(BaseConnection):
Process a pending packet.
"""
packet = self._dequeue()
self.logPacket('from', packet)
PACKET_LOGGER.log(self, packet, 'from')
self.handler.packetReceived(self, packet)
def pending(self):
......@@ -349,25 +349,12 @@ class Connection(BaseConnection):
self.handler.connectionClosed(self)
raise
def logPacket(self, direction, packet):
packet_type = packet.getType()
ip, port = self.getAddress()
if packet_type == protocol.ERROR:
code, message = packet.decode()
logging.debug('#0x%08x ERROR %-24s %s %s (%s:%d) %s',
packet.getId(), code, direction, dump(self.uuid),
ip, port, message)
else:
logging.debug('#0x%08x %-30s %s %s (%s:%d)', packet.getId(),
packet_type, direction, dump(self.uuid),
ip, port)
def _addPacket(self, packet):
"""Add a packet into the write buffer."""
if self.connector is None:
return
self.logPacket(' to ', packet)
PACKET_LOGGER.log(self, packet, ' to ')
try:
self.write_buf += packet.encode()
except PacketMalformedError, m:
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment