diff idavoll/idavoll.py @ 76:66fac7cd9edc

Added -v (--verbose) flag to print out all traffic.
author Ralph Meijer <ralphm@ik.nu>
date Mon, 08 Nov 2004 14:06:54 +0000
parents 1f7b8b6b8ce9
children a7196ca7cefd
line wrap: on
line diff
--- a/idavoll/idavoll.py	Sun Nov 07 14:47:02 2004 +0000
+++ b/idavoll/idavoll.py	Mon Nov 08 14:06:54 2004 +0000
@@ -109,6 +109,18 @@
 
         self.send(xmpp_error.error_from_iq(iq, 'service-unavailable'))
 
+class LogService(component.Service):
+
+    def transportConnected(self, xmlstream):
+        xmlstream.rawDataInFn = self.rawDataIn
+        xmlstream.rawDataOutFn = self.rawDataOut
+
+    def rawDataIn(self, buf):
+        print "RECV: %s" % buf.encode('ascii', 'replace')
+
+    def rawDataOut(self, buf):
+        print "SEND: %s" % buf.encode('ascii', 'replace')
+
 def makeService(config):
     serviceCollection = service.MultiService()
 
@@ -116,6 +128,9 @@
     sm = component.buildServiceManager(config["jid"], config["secret"],
             ("tcp:%s:%s" % (config["rhost"], config["rport"])))
 
+    if config["verbose"]:
+        LogService().setServiceParent(sm)
+
     if config['backend'] == 'pgsql':
         import pgsql_backend as b
         st = b.Storage(user=config['dbuser'], database=config['dbname'])