summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2020-10-16 15:14:12 +0200
committerAnton Khirnov <anton@khirnov.net>2020-10-16 15:14:12 +0200
commit63eef7e44e1ecb2ccf4c88237fab8731fddf48b3 (patch)
tree480d0e1a889e40fa5ebd3a752f3b3536bcb9042c
parent570a6183546c0197fe89d6356b561528921c8f54 (diff)
_ssh_client: add logging
-rw-r--r--lbup/_ssh_client.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/lbup/_ssh_client.py b/lbup/_ssh_client.py
index dec3390..18261b1 100644
--- a/lbup/_ssh_client.py
+++ b/lbup/_ssh_client.py
@@ -1,3 +1,5 @@
+import logging
+
import paramiko.client as pmc
from ._sshfp_policy import SSHFPPolicy
@@ -14,8 +16,12 @@ class SSHConnection:
_proxy_conn = None
_client = None
_remote = None
+ _logger = None
def __init__(self, remote):
+ self._logger = logging.getLogger('%s.%s' % (self.__class__.__name__, str(remote)))
+ self._logger.debug('Connecting to remote host...')
+
sock = None
if remote.proxy_remote is not None:
self._proxy_conn = SSHConnection(remote.proxy_remote)
@@ -27,9 +33,12 @@ class SSHConnection:
self._client.connect(remote.host, remote.port, remote.username,
sock = sock)
+ self._logger.debug('Connected to remote host')
self._remote = remote
def close(self):
+ self._logger.debug('Disconnecting from remote host')
+
if self._client:
self._client.close()
self._client = None
@@ -37,6 +46,8 @@ class SSHConnection:
self._proxy_conn.close()
self._proxy_conn = None
+ self._logger.debug('Disconnected from remote host')
+
def exec_command(self, *args, **kwargs):
return self._client.exec_command(*args, **kwargs)
def get_transport(self):