def onClose(self, wasClean, code, reason): """ WebSocket callback """ try: eliot.remove_destination(self._received_eliot_log) except ValueError: pass
def stopService(self): if self.capture_logs: globalLogPublisher.removeObserver(self.twisted_observer) self.stdlib_cleanup() if self.task is not None: self.task.finish() for dest in self.destinations: remove_destination(dest) return Service.stopService(self)
def _setUp(self): self.logs = [] add_destination(self.logs.append) self.addCleanup(lambda: remove_destination(self.logs.append)) self.addDetail( self.LOG_DETAIL_NAME, Content( UTF8_TEXT, # Safeguard the logs against _tearDown. Capture the list # object in the lambda's defaults. lambda logs=self.logs: [_eliottree(logs)], ), )
def test_tree(self): """ ``_eliottree`` returns a ``bytes`` string containing a rendered tree of Eliot actions and messages. """ events = [] add_destinations(events.append) self.addCleanup(lambda: remove_destination(events.append)) with start_action(action_type=u"foo"): pass # I don't know exactly what the tree rendering looks like. That's why # I'm using eliot-tree! So this assertion is sort of lame. self.assertThat( _eliottree(events), Contains(u"foo/1 \N{RIGHTWARDS DOUBLE ARROW} started"), )
def stopService(self): for dest in self.destinations: remove_destination(dest) globalLogPublisher.removeObserver(self.twisted_observer) self.stdlib_cleanup() return Service.stopService(self)
def __exit__(self, typ_, exc, tb): if exc: pprint(self.messages) eliot.remove_destination(self)