How can I output what SUDs is generating/receiving? How can I output what SUDs is generating/receiving? python python

How can I output what SUDs is generating/receiving?


SUDS provides some convenience methods to do just that:

 client.last_sent() client.last_received()

These should provide you with what you need. I use them for error logging.The API doc for Client class should have any extra info you need.


You can use the MessagePlugin to do this (this will work on the newer Jurko fork where last_sent and last_received have been removed)

from suds.plugin import MessagePluginclass LogPlugin(MessagePlugin):  def sending(self, context):    print(str(context.envelope))  def received(self, context):    print(str(context.reply))client = Client("http://localhost/wsdl.wsdl", plugins=[LogPlugin()])


Suds supports internal logging, as you have been doing.

I am setting info levels like you:

logging.getLogger('suds.client').setLevel(logging.DEBUG)logging.getLogger('suds.transport').setLevel(logging.DEBUG) # MUST BE THIS?logging.getLogger('suds.xsd.schema').setLevel(logging.DEBUG)logging.getLogger('suds.wsdl').setLevel(logging.DEBUG)logging.getLogger('suds.resolver').setLevel(logging.DEBUG)logging.getLogger('suds.xsd.query').setLevel(logging.DEBUG)logging.getLogger('suds.xsd.basic').setLevel(logging.DEBUG)logging.getLogger('suds.binding.marshaller').setLevel(logging.DEBUG)

And I also sometimes need to override the root logger logging level, depending on the framework being used under Suds calls (Django, Plone). If the root logger has a higher logging threshold, log messaegs may never appear (not sure how logger hierarchies should go). Below is an example how to override:

def enableDebugLog(self):    """ Enable context.plone_log() output from Python scripts """    import sys, logging    logger = logging.getLogger()            logger.root.setLevel(logging.DEBUG)    logger.root.addHandler(logging.StreamHandler(sys.stdout))