<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Jul 12, 2012, at 1:31 PM, Dan Milstein &lt;<a href="mailto:dan@wingu.com">dan@wingu.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">'lo all,<br><br>I've been doing some work with the twisted.mail.imap4 module, and its associated unit tests (in order to learn the code more, I'm tackling a few of the outstanding tickets).<br><br>When running those tests, I'd often like to log all the server/client interaction. &nbsp;I managed to do so by way of hacking the code in twisted.protocols.loopback, but that feels pretty wrong. &nbsp;What's a good way to get all the interaction logged?<br><br>To be more specific, the tests in question (e.g. test_imap.NewFetchTestCase), do a lot of:<br><br> &nbsp;&nbsp;&nbsp;d = loopback.loopbackTCP(self.server, self.client, noisy=False)<br> &nbsp;&nbsp;&nbsp;d.addCallback(lambda x : self.assertEqual(self.result, self.expected))<br> &nbsp;&nbsp;&nbsp;return d<br><br>What's a Good Way to get all the traffic going over that loopback logged? &nbsp;Setting noisy to True merely gets it to log some protocol startup/teardown-type messages. &nbsp;<br><br>Or: given that I've figured out how to hack loopback.lookupbackTCP, if there's general utility, I can certainly add a keyword arg to trigger logging of all messages, e.g. logAll=False (I'm trying to find something which feels meaningfully different from 'noisy', because it would seem Very Wrong Indeed to make noisy suddenly produce vastly more log output). &nbsp;Is that something people might be interested in?<br><br></blockquote><br></div><div>If you're interested in logging at the TCP connection level, have you considered moving this out of your Twisted process entirely and using some tool like Wireshark? &nbsp;You <i>could</i>&nbsp;build something yourself by interposing transport objects that dump their data, but you'd have to build your own toolchain (command line tools, GUIs, etc) for actually examining the output, whereas existing protocol analysis tools would just do that for you.</div><div><br></div><div>-glyph</div><div><br></div><br></body></html>