issue #275: Tidier SSH debug logging.

pull/287/head
David Wilson 7 years ago
parent 3b1cc3676c
commit 60ad75f436

@ -58,8 +58,10 @@ def _filter_debug(stream, it, buf):
if not buf.startswith(DEBUG_PREFIXES): if not buf.startswith(DEBUG_PREFIXES):
return buf return buf
while '\n' in buf: while '\n' in buf:
if not buf.startswith(DEBUG_PREFIXES):
return buf
line, _, buf = buf.partition('\n') line, _, buf = buf.partition('\n')
LOG.debug('%r: received %r', stream, line.rstrip()) LOG.debug('%r: %s', stream, line.rstrip())
try: try:
buf += next(it) buf += next(it)
except StopIteration: except StopIteration:
@ -77,7 +79,8 @@ def filter_debug(stream, it):
for chunk in it: for chunk in it:
chunk = _filter_debug(stream, it, chunk) chunk = _filter_debug(stream, it, chunk)
if chunk: if chunk:
yield chunk for line in chunk.splitlines():
yield line
class PasswordError(mitogen.core.StreamError): class PasswordError(mitogen.core.StreamError):
@ -219,7 +222,7 @@ class Stream(mitogen.parent.Stream):
for buf in filter_debug(self, it): for buf in filter_debug(self, it):
LOG.debug('%r: received %r', self, buf) LOG.debug('%r: received %r', self, buf)
if buf.endswith('EC0\n'): if buf.endswith('EC0'):
self._router.broker.start_receive(self.tty_stream) self._router.broker.start_receive(self.tty_stream)
self._ec0_received() self._ec0_received()
return return

Loading…
Cancel
Save