[Neo-report] r2740 jm - in /trunk/neo/lib: connection.py logger.py

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Apr 28 21:46:43 CEST 2011


Author: jm
Date: Thu Apr 28 21:46:42 2011
New Revision: 2740

Log:
Slightly reduce width of logs generated by packet logger

Modified:
    trunk/neo/lib/connection.py
    trunk/neo/lib/logger.py

Modified: trunk/neo/lib/connection.py
==============================================================================
--- trunk/neo/lib/connection.py [iso-8859-1] (original)
+++ trunk/neo/lib/connection.py [iso-8859-1] Thu Apr 28 21:46:42 2011
@@ -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):

Modified: trunk/neo/lib/logger.py
==============================================================================
--- trunk/neo/lib/logger.py [iso-8859-1] (original)
+++ trunk/neo/lib/logger.py [iso-8859-1] Thu Apr 28 21:46:42 2011
@@ -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)




More information about the Neo-report mailing list