Skip to content

Commit ebe6700

Browse files
committed
ssh: don't use a separate logger
The logger setup was confusing when using --log-file-level=DEBUG, showing this debug-level output inside default --log-cli-level=INFO output, but without the debug context that only went into the logfile, and without any hint of what kind of output it was. This makes it use the same logger as all other debug output, preventing it from appearing in the wrong place, and adds a marker to hint it is output data - at the same time fixing a potential formatting issue, where arbitrary ssh output lines were interpreted as *format strings*. Signed-off-by: Yann Dirson <[email protected]>
1 parent 83ff609 commit ebe6700

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

lib/commands.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,6 @@ def _ellide_log_lines(log):
5959
reduced_message.append("(...)")
6060
return "\n{}".format("\n".join(reduced_message))
6161

62-
OUPUT_LOGGER = logging.getLogger('output')
63-
OUPUT_LOGGER.propagate = False
64-
OUTPUT_HANDLER = logging.StreamHandler()
65-
OUPUT_LOGGER.addHandler(OUTPUT_HANDLER)
66-
OUTPUT_HANDLER.setFormatter(logging.Formatter('%(message)s'))
67-
6862
def _ssh(hostname_or_ip, cmd, check, simple_output, suppress_fingerprint_warnings,
6963
background, target_os, decode, options):
7064
opts = list(options)
@@ -111,7 +105,7 @@ def _ssh(hostname_or_ip, cmd, check, simple_output, suppress_fingerprint_warning
111105
for line in iter(process.stdout.readline, b''):
112106
readable_line = line.decode(errors='replace').strip()
113107
stdout.append(line)
114-
OUPUT_LOGGER.debug(readable_line)
108+
logging.debug("> %s", readable_line)
115109
_, stderr = process.communicate()
116110
res = subprocess.CompletedProcess(ssh_cmd, process.returncode, b''.join(stdout), stderr)
117111

0 commit comments

Comments
 (0)