File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ Fixed log level mapping to cover whole libssh range -- by :user: `Jakuje `.
2+
3+ Previously, it was not possible to set most verbose libssh log level
4+ ``SSH_LOG_TRACE `` to get most verbose log messages useful for debugging
5+ connection issues. To set pylibssh session verbosity to this level, you
6+ can use the following snippet:
7+
8+ from pylibsshext.logging import ANSIBLE_PYLIBSSH_TRACE
9+
10+ # Initializes the new TRACE log level in python logging system
11+ ssh_session = Session()
12+
13+ eh = logging.StreamHandler()
14+ eh.setLevel(logging.ERROR)
15+
16+ dh = logging.FileHandler('ansible-libssh-errors.log')
17+ dh.setLevel(ANSIBLE_PYLIBSSH_TRACE)
18+
19+ logging.getLogger('ansible-pylibssh').addHandler(eh)
20+ logging.getLogger('ansible-pylibssh').addHandler(dh)
21+
22+ ssh_session.set_log_level(ANSIBLE_PYLIBSSH_TRACE)
23+ ssh_session.connect(...)
24+
25+ This is based on :external+python:std:ref: `logging-cookbook ` and
26+ :external+python:std:ref: `logging-howto `.
Original file line number Diff line number Diff line change 1+ Made libssh use the Python :py:mod: `logging ` system -- by :user: `Jakuje `.
2+
3+ Previously, the logging was done by underlying C-code to stderr instead,
4+ which caused inconsistent behavior.
5+
6+ The default log level is now set to ``ANSIBLE_PYLIBSSH_TRACE ``
7+ and donstream loggers are able to trim the verbosity down.
8+ If you need a performance, you can avoid logging on the libssh
9+ side at source by setting lower logging value, for example:
10+
11+ ```
12+ ssh_session.set_log_level(ANSIBLE_PYLIBSSH_NOLOG)
13+ ```
You can’t perform that action at this time.
0 commit comments