Skip to content

can transport log not split up error tracebacks? #405

Closed

Description

@bninja

when transport catches exceptions it splits tb into multiple strings:

paramiko/paramiko/transport.py

Lines 1633 to 1634 in 1af8db2

self._log(ERROR, 'Exception: ' + str(e))
self._log(ERROR, util.tb_strings())

which are then logged separately:

paramiko/paramiko/transport.py

Lines 1423 to 1428 in 1af8db2

def _log(self, level, msg, *args):
if issubclass(type(msg), list):
for m in msg:
self.logger.log(level, m)
else:
self.logger.log(level, msg, *args)

making it hard to e.g. filter a specific "error" in server mode.

would it make sense to just pass along whatever exc_info is being handled to logging and let it do formatting as a single msg?

Activity

  1. bitprophet commented on Sep 30, 2014

    @bitprophet
    Member

    Sounds like a reasonable request offhand; I'd probably merge such a PR.

    Also, do you have concrete examples of what this looks like in the wild? I can guess at how it'll look but it's always nice to have actual snippets.

  2. bninja commented on Sep 30, 2014

    @bninja
    Author

    great, wasnt sure if there is a special reason i miss. here's paramiko sftp server:

    2014-09-30 06:23:32,781 : ERROR : paramiko.transport : 15421 : Thread-2 : Exception: Error reading SSH protocol banner
    2014-09-30 06:23:32,787 : ERROR : paramiko.transport : 15421 : Thread-2 : Traceback (most recent call last):
    2014-09-30 06:23:32,788 : ERROR : paramiko.transport : 15421 : Thread-2 :   File "/usr/local/lib/python2.7/dist-packages/paramiko/transport.py", line 1413, in run
    2014-09-30 06:23:32,789 : ERROR : paramiko.transport : 15421 : Thread-2 :     self._check_banner()
    2014-09-30 06:23:32,789 : ERROR : paramiko.transport : 15421 : Thread-2 :   File "/usr/local/lib/python2.7/dist-packages/paramiko/transport.py", line 1540, in _check_banner
    2014-09-30 06:23:32,790 : ERROR : paramiko.transport : 15421 : Thread-2 :     raise SSHException('Error reading SSH protocol banner' + str(e))
    2014-09-30 06:23:32,791 : ERROR : paramiko.transport : 15421 : Thread-2 : SSHException: Error reading SSH protocol banner
    2014-09-30 06:23:32,792 : ERROR : paramiko.transport : 15421 : Thread-2 : 
    

    while other logged exceptions w/ tb look like:

    2014-09-29 08:32:52,879 : ERROR : ciao : 18570 : Dummy-503 : (OperationalError) FATAL:  remaining connection slots are reserved for non-replication superuser connections
     None None
    Traceback (most recent call last):
    ...
    

    didnt care so much about the looks tho, more a problem if need to operate on a single log msg thats been split like this (e.g.filtering).

  3. bitprophet commented on Sep 30, 2014

    @bitprophet
    Member

    It's possible there's a special reason I'm unaware of (I didn't write Paramiko originally) but I really can't think of any offhand and the "have a full exception as a single log message" point is a very valid one.

    Anyway, closing this in favor of the PR, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions