From d9c604dcd8bf0ced1b14f02a192c4283f06804ee Mon Sep 17 00:00:00 2001 From: Georgy Frolov Date: Sun, 14 Feb 2021 17:07:09 +0300 Subject: [PATCH] added ssh connection logs --- mycli/packages/ssh_client/client.py | 11 +++++++++++ mycli/sqlexecute.py | 7 ++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/mycli/packages/ssh_client/client.py b/mycli/packages/ssh_client/client.py index 1df96fae..4403f297 100644 --- a/mycli/packages/ssh_client/client.py +++ b/mycli/packages/ssh_client/client.py @@ -1,6 +1,9 @@ """A very thin wrapper around paramiko, mostly to keep all SSH-related functionality in one place.""" from io import open +import logging + +_logger = logging.getLogger(__name__) try: import paramiko @@ -23,6 +26,14 @@ def create_ssh_client(ssh_host, ssh_port, ssh_user, ssh_password=None, ssh_key_f client = paramiko.SSHClient() client.load_system_host_keys() client.set_missing_host_key_policy(paramiko.WarningPolicy()) + _logger.debug( + f'Connecting to ssh server with \n' + ' host = {ssh_host}\n' + ' port = {ssh_port}\n' + ' user = {ssh_user}\n' + ' password = {ssh_password}\n' + ' key_filename = {ssh_key_filename}\n' + ) client.connect( ssh_host, ssh_port, ssh_user, password=ssh_password, key_filename=ssh_key_filename ) diff --git a/mycli/sqlexecute.py b/mycli/sqlexecute.py index 2576023c..5529974e 100644 --- a/mycli/sqlexecute.py +++ b/mycli/sqlexecute.py @@ -79,10 +79,11 @@ def connect(self, database=None, user=None, password=None, host=None, '\tsocket: %r' '\tcharset: %r' '\tlocal_infile: %r' - '\tssl: %r', - '\tinit_command: %r', + '\tssl: %r' + '\tinit_command: %r' + '\tusing ssh: %r', db, user, host, port, socket, charset, local_infile, ssl, - init_command + init_command, bool(ssh_client) ) conv = conversions.copy() conv.update({