[Twisted-Python] XMLRPC, how to prevent stdout on post and get?
exarkun at twistedmatrix.com
exarkun at twistedmatrix.com
Tue Jul 19 21:39:04 EDT 2011
On 19 Jul, 06:57 pm, happybrowndog at hotmail.com wrote:
>On 7/19/2011 11:11 AM, Paul Thomas wrote:
>>As a quick fix,
>>
>>class QuietSite(server.Site):
>> """Like a Site but quieter"""
>> def log(self, request):
>> pass
>>
>>Then use QuietSite instead of server.Site
>>
>>p.
>>On 19 Jul 2011, at 08:37, hbd666 wrote:
>>>I have a simple xmlrpc server written using Twisted. Every time I
>>>get a
>>>request to it, stdout spits out something like the following:
>>>
>>>2011-07-19 00:33:39-0700 [HTTPChannel,332,127.0.0.1] 127.0.0.1 - -
>>>[19/Jul/2011:07:33:38 +0000] "POST / HTTP/1.0" 200 128 "-"
>>>"xmlrpclib.py/1.0.1 (by www.pythonware.com)"
>>>
>>>
>>>How do I prevent this from happening? I also do not want this going
>>>to
>>>a log file either.
>>>
>>>Thanks anybody for your help!
>>>
>>>
>>>
>>>_______________________________________________
>>>Twisted-Python mailing list
>>>Twisted-Python at twistedmatrix.com
>>>http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>
>Thanks, that worked for my application.
>Though I still do see a need to modify the API as suggested earlier,
>because it would be more specific to the XMLRPC, and just in case there
>is more than one protocol for a server site for an application -
>wouldn't want to kill logging for all protocols.
Hmmm. Site is a factory for HTTP. XML-RPC runs over HTTP. There isn't
really a different protocol here. It sounds more like you want to
disable logging for certain request URLs, perhaps. You can do that by
writing a suitable log method, eg:
class SiteWithoutXMLRPCLogging(Site):
def log(self, request):
if request.uri.startswith('/RPC2') and request.method ==
'POST':
return
return Site.log(self, request)
It might be nicer if the response was also available, though
(particularly since the request isn't logged until the response is
generated). Then you could avoid encoding the "/RPC2" string (which
often isn't actually used) and do something like an isinstance(resource,
XMLRPC).
Jean-Paul
More information about the Twisted-Python
mailing list