[Neo-report] r2816 jm - in /trunk/neo: lib/logger.py tests/testConnection.py

nobody at svn.erp5.org nobody at svn.erp5.org
Sat Sep 3 17:44:26 CEST 2011


Author: jm
Date: Sat Sep  3 17:44:25 2011
New Revision: 2816

Log:
Log first 96 bytes of packets

Modified:
    trunk/neo/lib/logger.py
    trunk/neo/tests/testConnection.py

Modified: trunk/neo/lib/logger.py
==============================================================================
--- trunk/neo/lib/logger.py [iso-8859-1] (original)
+++ trunk/neo/lib/logger.py [iso-8859-1] Sat Sep  3 17:44:25 2011
@@ -15,6 +15,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
+from base64 import b64encode
 import neo
 from neo.lib.protocol import PacketMalformedError
 from neo.lib.util import dump
@@ -38,8 +39,9 @@ class PacketLogger(object):
         uuid = dump(conn.getUUID())
         ip, port = conn.getAddress()
         packet_name = packet.__class__.__name__
-        neo.lib.logging.debug('#0x%04x %-30s %s %s (%s:%d)', packet.getId(),
-                packet_name, outgoing and '>' or '<', uuid, ip, port)
+        neo.lib.logging.debug('#0x%04x %-30s %s %s (%s:%d) %s', packet.getId(),
+                packet_name, outgoing and '>' or '<', uuid, ip, port,
+                b64encode(packet._body[:96]))
         # look for custom packet logger
         logger = getattr(self, packet.handler_method_name, None)
         if logger is None:

Modified: trunk/neo/tests/testConnection.py
==============================================================================
--- trunk/neo/tests/testConnection.py [iso-8859-1] (original)
+++ trunk/neo/tests/testConnection.py [iso-8859-1] Sat Sep  3 17:44:25 2011
@@ -371,6 +371,7 @@ class ConnectionTests(NeoUnitTestBase):
     def test_07_Connection_addPacket(self):
         # new packet
         p = Mock({"encode" : "testdata", "getId": 0})
+        p._body = ''
         p.handler_method_name = 'testmethod'
         bc = self._makeConnection()
         self._checkWriteBuf(bc, '')




More information about the Neo-report mailing list