aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJake Hunsaker <jhunsake@redhat.com>2023-01-10 11:43:49 -0500
committerJake Hunsaker <jhunsake@redhat.com>2023-01-11 09:35:21 -0500
commit006629773a6ef1a8517c15d8b64dd7943da714a9 (patch)
treef410f3091fe7ef1eeaf9f82a609b3f7ded6d0e85
parent684f3acb5a82215cc1cb07c5ea78853e91e3834c (diff)
downloadsos-006629773a6ef1a8517c15d8b64dd7943da714a9.tar.gz
[cleaner] Convert print()s to leveraging ui logging
It was recently found that some condition will cause Avocado to not capture trailing `print()` statements in our test suite, and it is reasonable to assume other automation may also have similar edge cases. Resolve this by switching potentially problematic `print()`s to use the ui logging stream, which will still print to console even after the file handler has been closed. Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
-rw-r--r--sos/cleaner/__init__.py24
1 files changed, 14 insertions, 10 deletions
diff --git a/sos/cleaner/__init__.py b/sos/cleaner/__init__.py
index 5e73bf98..d3e32992 100644
--- a/sos/cleaner/__init__.py
+++ b/sos/cleaner/__init__.py
@@ -139,7 +139,7 @@ class SoSCleaner(SoSComponent):
_loaded_name = _loaded.name.lower().split('parser')[0].strip()
if _parser.lower().strip() == _loaded_name:
self.log_info("Disabling parser: %s" % _loaded_name)
- self.ui_log.warn(
+ self.ui_log.warning(
"Disabling the '%s' parser. Be aware that this may "
"leave sensitive plain-text data in the archive."
% _parser
@@ -406,16 +406,20 @@ third party.
shutil.move(arc_path, final_path)
arcstat = os.stat(final_path)
- # logging will have been shutdown at this point
- print("A mapping of obfuscated elements is available at\n\t%s"
- % map_path)
-
- print("\nThe obfuscated archive is available at\n\t%s\n" % final_path)
- print("\tSize\t%s" % get_human_readable(arcstat.st_size))
- print("\tOwner\t%s\n" % getpwuid(arcstat.st_uid).pw_name)
+ # while these messages won't be included in the log file in the archive
+ # some facilities, such as our avocado test suite, will sometimes not
+ # capture print() output, so leverage the ui_log to print to console
+ self.ui_log.info(
+ f"A mapping of obfuscated elements is available at\n\t{map_path}"
+ )
+ self.ui_log.info(
+ f"\nThe obfuscated archive is available at\n\t{final_path}\n"
+ )
- print("Please send the obfuscated archive to your support "
- "representative and keep the mapping file private")
+ self.ui_log.info(f"\tSize\t{get_human_readable(arcstat.st_size)}")
+ self.ui_log.info(f"\tOwner\t{getpwuid(arcstat.st_uid).pw_name}\n")
+ self.ui_log.info("Please send the obfuscated archive to your support "
+ "representative and keep the mapping file private")
self.cleanup()