Adjusted logging in TryAndPrint()

This commit is contained in:
2Shirt 2019-09-18 20:02:13 -07:00
parent 304d811698
commit f55f0ba016
Signed by: 2Shirt
GPG key ID: 152FAC923B0E132C
2 changed files with 9 additions and 2 deletions

View file

@ -10,7 +10,7 @@ DEBUG = {
DEFAULT = {
'level': 'INFO',
'format': '[%(asctime)s %(levelname)s] %(message)s',
'datefmt': '%Y-%m-%d %H:%M:%S %z',
'datefmt': '%Y-%m-%d %H%M%z',
}

View file

@ -463,6 +463,13 @@ class TryAndPrint():
obj = getattr(sys.modules['builtins'], name)
return obj
def _log_result(self, message, result_msg):
"""Log result text without color formatting."""
log_text = f'{" "*self.indent}{message:<{self.width}}{result_msg}'
for line in log_text.splitlines():
line = strip_colors(line)
LOG.info(line)
def add_error(self, exception_name):
"""Add exception name to error list."""
if exception_name not in self.list_errors:
@ -539,7 +546,7 @@ class TryAndPrint():
raise
# Done
LOG.info('Result: %s', result_msg.strip())
self._log_result(message, result_msg)
return {
'Failed': bool(f_exception),
'Exception': f_exception,