Skip to content

Commit

Permalink
Merge pull request #250 from xcp-ng/ssh-logging
Browse files Browse the repository at this point in the history
ssh: don't use a separate logger
  • Loading branch information
stormi authored Sep 4, 2024
2 parents 9487e38 + 6c18d35 commit 56fa202
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
8 changes: 1 addition & 7 deletions lib/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,6 @@ def _ellide_log_lines(log):
reduced_message.append("(...)")
return "\n{}".format("\n".join(reduced_message))

OUPUT_LOGGER = logging.getLogger('output')
OUPUT_LOGGER.propagate = False
OUTPUT_HANDLER = logging.StreamHandler()
OUPUT_LOGGER.addHandler(OUTPUT_HANDLER)
OUTPUT_HANDLER.setFormatter(logging.Formatter('%(message)s'))

def _ssh(hostname_or_ip, cmd, check, simple_output, suppress_fingerprint_warnings,
background, target_os, decode, options):
opts = list(options)
Expand Down Expand Up @@ -111,7 +105,7 @@ def _ssh(hostname_or_ip, cmd, check, simple_output, suppress_fingerprint_warning
for line in iter(process.stdout.readline, b''):
readable_line = line.decode(errors='replace').strip()
stdout.append(line)
OUPUT_LOGGER.debug(readable_line)
logging.debug("> %s", readable_line)
_, stderr = process.communicate()
res = subprocess.CompletedProcess(ssh_cmd, process.returncode, b''.join(stdout), stderr)

Expand Down
3 changes: 2 additions & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[pytest]
addopts = -ra --maxfail=1 -s
addopts = -ra --maxfail=1
markers =
# *** Markers that change test behaviour ***
default_vm: mark a test with a default VM in case no --vm parameter was given.
Expand Down Expand Up @@ -28,6 +28,7 @@ markers =
flaky: flaky tests. Usually pass, but sometimes fail unexpectedly.
complex_prerequisites: tests whose prerequisites are complex and may require special attention.
quicktest: runs `quicktest`.
log_level = debug
log_cli = 1
log_cli_level = info
log_format = %(asctime)s.%(msecs)03d %(levelname)s %(message)s
Expand Down

0 comments on commit 56fa202

Please sign in to comment.