diff --git a/pmpsdb_client/cli/__init__.py b/pmpsdb_client/cli/__init__.py index 1d38b06..3ed958f 100644 --- a/pmpsdb_client/cli/__init__.py +++ b/pmpsdb_client/cli/__init__.py @@ -47,7 +47,10 @@ def _main(args: argparse.Namespace) -> int: print(version) return 0 if args.verbose: - logging.basicConfig(level=logging.DEBUG) + logging.basicConfig( + level=logging.DEBUG, + format="%(asctime)s %(levelname)s: %(name)s %(message)s", + ) else: logging.basicConfig( level=logging.INFO, diff --git a/pmpsdb_client/plc_data.py b/pmpsdb_client/plc_data.py index 6067918..b7226bc 100644 --- a/pmpsdb_client/plc_data.py +++ b/pmpsdb_client/plc_data.py @@ -63,21 +63,27 @@ def list_file_info( data_method = DataMethod.unk if data_method == DataMethod.ssh: + logger.debug("Using cached ssh method to list files for %s", hostname) return ssh_data.list_file_info(hostname=hostname, directory=directory) elif data_method == DataMethod.ftp: + logger.debug("Using cached ftp method to list files for %s", hostname) return ftp_data.list_file_info(hostname=hostname, directory=directory) elif data_method == DataMethod.unk: + logger.debug("Connection method unknown, check if ssh method works for %s", hostname) try: file_info = ssh_data.list_file_info(hostname=hostname, directory=directory) except Exception: + logger.debug("ssh failed, check if ftp method works for %s", hostname) try: file_info = ftp_data.list_file_info(hostname=hostname, directory=directory) except Exception: raise RuntimeError(f"Cannot get data method for {hostname}") else: + logger.debug("Cache %s method as ftp", hostname) plc_mapping[hostname] = DataMethod.ftp return file_info else: + logger.debug("Cache %s method as ssh", hostname) plc_mapping[hostname] = DataMethod.ssh return file_info else: