Even more logging fixes (#757)
All checks were successful
Lint Checks / Run linter (push) Successful in 57s
Publish / Build and publish (push) Successful in 1m40s
Deploy Test / Run deploy test suite (push) Successful in 3m46s
Webapp Test / Run webapp test suite (push) Successful in 4m48s
Smoke Test / Run basic test suite (push) Successful in 5m7s

Hopefully the last one for a bit.

This only output the cmdline if log_file is present (ie, not to stdout).  It also fixes a bug where the log_file was not passed in one line.

Reviewed-on: #757
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
This commit is contained in:
Thomas E Lackey 2024-02-22 01:24:44 +00:00 committed by Thomas E Lackey
parent 4a4d48ddb9
commit 6bd77c893a

View File

@ -40,12 +40,17 @@ class AttrDict(dict):
def logged_cmd(log_file, *vargs):
result = None
try:
if log_file:
print(" ".join(vargs), file=log_file)
result = subprocess.run(vargs, capture_output=True, stdout=log_file, stderr=log_file)
result = subprocess.run(vargs, capture_output=True)
result.check_returncode()
return result.stdout.decode()
except Exception as err:
if result:
print(result.stderr.decode(), file=log_file)
else:
print(str(err), file=log_file)
raise err
@ -184,7 +189,7 @@ class LaconicRegistryClient:
self.set_name(name, new_record_id)
return new_record_id
finally:
logged_cmd("rm", "-rf", tmpdir)
logged_cmd(self.log_file, "rm", "-rf", tmpdir)
def set_name(self, name, record_id):
logged_cmd(self.log_file, "laconic", "-c", self.config_file, "cns", "name", "set", name, record_id)