[Twisted-Python] Getting nice logging outputs in py.test

Thomas Westfeld thomas.westfeld at currenta.de
Fri Jul 5 06:09:45 MDT 2019


>-----Original Message-----
>From: Twisted-Python [mailto:twisted-python-bounces at twistedmatrix.com] On
>Behalf Of Amber Brown
>Sent: Friday, July 05, 2019 12:47 PM
>To: twisted-python at twistedmatrix.com
>Subject: Re: [Twisted-Python] Getting nice logging outputs in py.test
>
>On 5/7/19 8:27 pm, Thomas Westfeld wrote:
>>>> Dear all,
>>>>
>>>> I am having an issue with logging of my Twisted application. I am using 
>>>> the new
>>> twisted.logger framework. The output produced by twist or twistd when 
>>> runnning
>my
>>> plugin is nice.
>>>> However when running a test suite using py.test I only get this as an 
>>>> output to
>>> stdout:
>>>
>>> How are you running the reactor in your pytest suites? I've not found a
>>> sane way to do this and so would recommend sticking with trial, crufty
>>> and old though it feels...
>> Well actually I do not. I use the subprocess module to start the server 
>> using twist
>and then use requests in the tests to test the HTML server and compare the 
>results
>with the expected results.
>>
>> And yes py.test eats stdout but it is great as I need a good looking html 
>> test
>report which can be also customized and py.test gives me just this.
>>
>> Sounds like there is no easy way of configuring a nice stdout log...
>
>Oh, that's why.
>
>If twist detects something that isn't a terminal, it outputs JSON
>because it's not a human looking at it, which is easier for logging
>systems to consume than straight text.
>
>You can pass `--log-format=text` as a command line argument to twist to
>override this.
>

This worked fine. Thanks alot!

>- Amber
>
>_______________________________________________
>Twisted-Python mailing list
>Twisted-Python at twistedmatrix.com
>https://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 6137 bytes
Desc: not available
URL: </pipermail/twisted-python/attachments/20190705/022a0cf5/attachment-0002.bin>


More information about the Twisted-Python mailing list