def test_txlog_write_text(handler, framework_tx): """ Writing to a text stream is supported. """ pytest.importorskip("twisted.logger") from txaio.tx import _LogObserver out_file = StringIO() observer = _LogObserver(out_file) observer({ "log_format": "hi: {testentry}", "testentry": "hello", "log_level": observer.to_tx["info"], "log_time": 1442890018.002233 }) output = out_file.getvalue() assert u"hi: hello" in output
def test_txlog_write_text(handler, framework_tx): """ Writing to a text stream is supported. """ pytest.importorskip("twisted.logger") from txaio.tx import _LogObserver out_file = StringIO() observer = _LogObserver(out_file) observer({ "log_format": "hi: {testentry}", "testentry": "hello", "log_level": observer.to_tx["info"], "log_time": 1442890018.002233 }) output = out_file.getvalue() assert u"hi: hello" in output
def test_log_converter(handler, framework): pytest.importorskip("twisted.logger") # this checks that we can convert a plain Twisted Logger calling # failure() into a traceback on our observers. from twisted.logger import Logger from txaio.tx import _LogObserver out = six.StringIO() observer = _LogObserver(out) logger = Logger(observer=observer) try: raise RuntimeError("failed on purpose") except: logger.failure(None) output = out.getvalue() assert "failed on purpose" in output assert "Traceback" in output
def test_log_converter(handler, framework): pytest.importorskip("twisted.logger") # this checks that we can convert a plain Twisted Logger calling # failure() into a traceback on our observers. from twisted.logger import Logger from txaio.tx import _LogObserver out = six.StringIO() observer = _LogObserver(out) logger = Logger(observer=observer) try: raise RuntimeError("failed on purpose") except: logger.failure(None) output = out.getvalue() assert "failed on purpose" in output assert "Traceback" in output