Commit 908d8de1 authored by Julien Muchembled's avatar Julien Muchembled

Log first 96 bytes of packets

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2816 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 7c5b545a
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from base64 import b64encode
import neo import neo
from neo.lib.protocol import PacketMalformedError from neo.lib.protocol import PacketMalformedError
from neo.lib.util import dump from neo.lib.util import dump
...@@ -38,8 +39,9 @@ class PacketLogger(object): ...@@ -38,8 +39,9 @@ class PacketLogger(object):
uuid = dump(conn.getUUID()) uuid = dump(conn.getUUID())
ip, port = conn.getAddress() ip, port = conn.getAddress()
packet_name = packet.__class__.__name__ packet_name = packet.__class__.__name__
neo.lib.logging.debug('#0x%04x %-30s %s %s (%s:%d)', packet.getId(), neo.lib.logging.debug('#0x%04x %-30s %s %s (%s:%d) %s', packet.getId(),
packet_name, outgoing and '>' or '<', uuid, ip, port) packet_name, outgoing and '>' or '<', uuid, ip, port,
b64encode(packet._body[:96]))
# look for custom packet logger # look for custom packet logger
logger = getattr(self, packet.handler_method_name, None) logger = getattr(self, packet.handler_method_name, None)
if logger is None: if logger is None:
......
...@@ -371,6 +371,7 @@ class ConnectionTests(NeoUnitTestBase): ...@@ -371,6 +371,7 @@ class ConnectionTests(NeoUnitTestBase):
def test_07_Connection_addPacket(self): def test_07_Connection_addPacket(self):
# new packet # new packet
p = Mock({"encode" : "testdata", "getId": 0}) p = Mock({"encode" : "testdata", "getId": 0})
p._body = ''
p.handler_method_name = 'testmethod' p.handler_method_name = 'testmethod'
bc = self._makeConnection() bc = self._makeConnection()
self._checkWriteBuf(bc, '') self._checkWriteBuf(bc, '')
......
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