Commit 8270d116 authored by Julien Muchembled's avatar Julien Muchembled

Slightly reduce width of logs generated by packet logger

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2740 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 4a50b1c3
......@@ -162,7 +162,7 @@ class HandlerSwitcher(object):
@profiler_decorator
def _handle(self, connection, packet):
assert len(self._pending) == 1 or self._pending[0][0]
PACKET_LOGGER.dispatch(connection, packet, 'from')
PACKET_LOGGER.dispatch(connection, packet, False)
if connection.isClosed() and packet.ignoreOnClosedConnection():
neo.lib.logging.debug('Ignoring packet %r on closed connection %r',
packet, connection)
......@@ -497,13 +497,13 @@ class Connection(BaseConnection):
packet_type = packet.getType()
if packet_type == Packets.Ping:
# Send a pong notification
PACKET_LOGGER.dispatch(self, packet, 'from')
PACKET_LOGGER.dispatch(self, packet, False)
if not self.aborted:
self.answer(Packets.Pong(), packet.getId())
elif packet_type == Packets.Pong:
# Skip PONG packets, its only purpose is refresh the timeout
# generated upong ping. But still log them.
PACKET_LOGGER.dispatch(self, packet, 'from')
PACKET_LOGGER.dispatch(self, packet, False)
else:
self._queue.append(packet)
......@@ -627,7 +627,7 @@ class Connection(BaseConnection):
if was_empty:
# enable polling for writing.
self.em.addWriter(self)
PACKET_LOGGER.dispatch(self, packet, ' to ')
PACKET_LOGGER.dispatch(self, packet, True)
@not_closed
def notify(self, packet):
......
......@@ -32,14 +32,14 @@ class PacketLogger(object):
def enable(self, enabled):
self.dispatch = enabled and self._dispatch or (lambda *args, **kw: None)
def _dispatch(self, conn, packet, direction):
def _dispatch(self, conn, packet, outgoing):
"""This is a helper method to handle various packet types."""
# default log message
uuid = dump(conn.getUUID())
ip, port = conn.getAddress()
packet_name = packet.__class__.__name__
neo.lib.logging.debug('#0x%08x %-30s %s %s (%s:%d)', packet.getId(),
packet_name, direction, uuid, ip, port)
neo.lib.logging.debug('#0x%04x %-30s %s %s (%s:%d)', packet.getId(),
packet_name, outgoing and '>' or '<', uuid, ip, port)
# look for custom packet logger
logger = getattr(self, packet.handler_method_name, None)
if logger is None:
......@@ -52,7 +52,7 @@ class PacketLogger(object):
return
log_message = logger(conn, *args)
if log_message is not None:
neo.lib.logging.debug('#0x%08x %s', packet.getId(), log_message)
neo.lib.logging.debug('#0x%04x %s', packet.getId(), log_message)
def error(self, conn, code, message):
return "%s (%s)" % (code, message)
......
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