-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pass exc_info along when logging exs, dont split and log tb separately #406
base: main
Are you sure you want to change the base?
Conversation
I think this was done to get nicely formatted log messages. The only mention of it is in the old changelog about adding it. If we want to do this, we should remove all usages of tb_strings and the function: $ ag tb_strings
ChangeLog.1
2855: also i put bit_length into util and a tb_strings function which gets stack
paramiko/server.py
652: self.__transport._log(ERROR, util.tb_strings())
paramiko/sftp_server.py
106: self._log(DEBUG, util.tb_strings())
114: self._log(DEBUG, util.tb_strings())
paramiko/util.py
142:def tb_strings():
paramiko/transport.py
1634: self._log(ERROR, util.tb_strings())
1638: #self._log(DEBUG, util.tb_strings())
1652: self._log(ERROR, util.tb_strings()) |
I agree, I read those comments before hand. :) While I do think that the log locks nicer with the exceptions logged line for line, it's not really that usable. I'm also +1, if we remove the rest of the calls to that function. |
removed |
Thanks, that looks okay. I'd like a test for this; either @bninja can do it or I can do it whenever I merge. (No ETA on the 2.0 feature milestone right now but probably sometime this month, hopefully sooner.) |
Small improvment on the PR: You can simply use Also, is there any update on this? We've been struggling with this on our ELK stack as the splitting causes log-entries for every single line in the traceback. But what's worse, it make log entries not searchable. I was writing up a bug report but did not see that there was already #405 until I finished writing it and GitHub pointing out the similarity to me ;) I had written down a detail on it, and even though it is redundant with everything said in #405 I will copy/paste it below anyway, because it contains screenshots from how this affects ELK: In some exceptions, the traceback is split into lines and each line is logged separately. For example:
The lines pass the traceback to util.tb_strings which has a return-type of Fragmenting the traceback-message like this makes it almost impossible to search for log messages in a solution like an ELK stack. It also artificially inflates the count of error-messages considerably (which we monitor). See the following screenshot for example: With messages like these, I cannot apply any useful filtering because if I do, I get only a fragment of the traceback. If I add a filter for A better solution would be to use
A quick "grep" around the code-base also shows that |
Transport._log() does not take msg list, it takes format string SFTPClient/SFTPServer _log() method does not take msg list SFTPBase gets new _loglist() method for the rare list case Transport and SFTP* use proper logging format strings and separate arguments SSHClient and AuthHandler always log with single msg string, so pass to Transport._log() as "%s", msg get rid of util.tb_strings(), instead _log() with exc_info=True so that lines of traceback are not separate log messages (inspired by paramiko#406)
Transport._log() does not take msg list, it takes format string SFTPClient/SFTPServer _log() method does not take msg list SFTPBase gets new _loglist() method for the rare list case Transport and SFTP* use proper logging format strings and separate arguments SSHClient and AuthHandler always log with single msg string, so pass to Transport._log() as "%s", msg get rid of util.tb_strings(), instead _log() with exc_info=True so that lines of traceback are not separate log messages (inspired by paramiko#406)
Transport._log() does not take msg list, it takes format string SFTPClient/SFTPServer _log() method does not take msg list SFTPBase gets new _loglist() method for the rare list case Transport and SFTP* use proper logging format strings and separate arguments SFTPClient no longer needs %% escaping of log messages, now that it logs correctly SSHClient and AuthHandler always log with single msg string, so pass to Transport._log() as "%s", msg get rid of util.tb_strings(), instead _log() with exc_info=True so that lines of traceback are not separate log messages (inspired by paramiko#406)
Transport._log() does not take msg list, it takes format string SFTPClient/SFTPServer _log() method does not take msg list SFTPBase gets new _loglist() method for the rare list case Transport and SFTP* use proper logging format strings and separate arguments SFTPClient no longer needs %% escaping of log messages, now that it logs correctly SSHClient and AuthHandler always log with single msg string, so pass to Transport._log() as "%s", msg get rid of util.tb_strings(), instead _log() with exc_info=True so that lines of traceback are not separate log messages (inspired by paramiko#406) binascii.hexlify() returns bytes, decode to string for logging (inspired by paramiko#1661)
Transport._log() does not take msg list, it takes format string SFTPClient/SFTPServer _log() method does not take msg list SFTPBase gets new _loglist() method for the rare list case Transport and SFTP* use proper logging format strings and separate arguments SFTPClient no longer needs %% escaping of log messages, now that it logs correctly SSHClient and AuthHandler always log with single msg string, so pass to Transport._log() as "%s", msg get rid of util.tb_strings(), instead _log() with exc_info=True so that lines of traceback are not separate log messages (inspired by paramiko#406) binascii.hexlify() returns bytes, decode to string for logging (inspired by paramiko#1661)
Transport._log() does not take msg list, it takes format string SFTPClient/SFTPServer _log() method does not take msg list SFTPBase gets new _loglist() method for the rare list case Transport and SFTP* use proper logging format strings and separate arguments SFTPClient no longer needs %% escaping of log messages, now that it logs correctly SSHClient and AuthHandler always log with single msg string, so pass to Transport._log() as "%s", msg get rid of util.tb_strings(), instead _log() with exc_info=True so that lines of traceback are not separate log messages (inspired by paramiko#406) binascii.hexlify() returns bytes, decode to string for logging (inspired by paramiko#1661)
Transport._log() does not take msg list, it takes format string SFTPClient/SFTPServer _log() method does not take msg list SFTPBase gets new _loglist() method for the rare list case Transport and SFTP* use proper logging format strings and separate arguments SFTPClient no longer needs %% escaping of log messages, now that it logs correctly SSHClient and AuthHandler always log with single msg string, so pass to Transport._log() as "%s", msg get rid of util.tb_strings(), instead _log() with exc_info=True so that lines of traceback are not separate log messages (inspired by paramiko#406) binascii.hexlify() returns bytes, decode to string for logging (inspired by paramiko#1661)
ends up looking like this now as single log msg:
closes #405