[Twisted-Python] Getting nice logging outputs in py.test
Thomas Westfeld
thomas.westfeld at currenta.de
Thu Jul 4 07:39:50 MDT 2019
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:
{"log_io": "\"127.0.0.1\" - - [04/Jul/2019:13:12:04 +0000] \"GET /index HTTP/1.1\" 401 - \"-\" \"python-requests/2.22.0\"", "log_logger": {"unpersistable": true}, "log_level": {"name": "info", "__class_uuid__": "02e59486-f24d-46ad-8224-3acdf2a5732a"}, "log_namespace": "twisted.python.log", "log_source": null, "log_format": "{log_io}", "log_time": 1562245925.0769854, "log_flattened": {"log_io!s:": "\"127.0.0.1\" - - [04/Jul/2019:13:12:04 +0000] \"GET /index HTTP/1.1\" 401 - \"-\" \"python-requests/2.22.0\"", "log_io!:": "\"127.0.0.1\" - - [04/Jul/2019:13:12:04 +0000] \"GET /index HTTP/1.1\" 401 - \"-\" \"python-requests/2.22.0\""}}
I tried to initialize a log observer like this, to get it better formatted:
globalLogBeginner.beginLoggingTo([textFileLogObserver(sys.stdout)])
But it does not work. I did this in a conftest.py file, but it did not produce the desired input.
Any idea how I can produce a nice log output to stdout?
Thanks in advance,
Thomas
More information about the Twisted-Python
mailing list