From 694b57d5fa003c787721dc79e9e9ca1344a74f2d Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Tue, 8 Aug 2023 01:19:00 -0500 Subject: [PATCH] fix: only log debug if not error --- src/viv/viv.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/viv/viv.py b/src/viv/viv.py index 6705872..65dece7 100755 --- a/src/viv/viv.py +++ b/src/viv/viv.py @@ -53,7 +53,7 @@ from typing import ( from urllib.error import HTTPError from urllib.request import urlopen -__version__ = "23.8a1-15-g3a2832e-dev" +__version__ = "23.8a1-16-g1a254a5-dev" class Spinner: @@ -729,8 +729,7 @@ def run( verbose: If true, print subcommand output. """ - # TODO: remove 'verbose' and rely on log level? - log.debug("executing subcmd\n\t" + " ".join(command)) + log.debug("executing subcmd:\n " + " ".join(command)) if spinmsg and not verbose: with Spinner(spinmsg): @@ -748,11 +747,6 @@ def run( universal_newlines=True, ) - if not verbose: - log.debug( - "output:\n" + "\n".join(f"-> {line}" for line in p.stdout.splitlines()) - ) - if p.returncode != 0 and not ignore_error: a.subprocess(command, p.stdout) @@ -761,7 +755,12 @@ def run( sys.exit(p.returncode) - elif check_output: + if not verbose: + log.debug( + "output:\n" + "\n".join(f"-> {line}" for line in p.stdout.splitlines()) + ) + + if check_output: return p.stdout else: