changeset 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 b8958967f508
files idavoll/idavoll.py idavoll/tap.py
diffstat 2 files changed, 17 insertions(+), 0 deletions(-) [+]
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'])
--- a/idavoll/tap.py	Sun Nov 07 14:47:02 2004 +0000
+++ b/idavoll/tap.py	Mon Nov 08 14:06:54 2004 +0000
@@ -13,6 +13,8 @@
 		('dbuser', None, ''),
 		('dbname', None, 'pubsub'),
 	]
+
+	optFlags = [('verbose', 'v', 'Show traffic')]
 	
 	def postOptions(self):
 		if self['backend'] not in ['pgsql', 'memory']: