Only strip trailing whitespace from console logs

Logs may have whitespace prefixing used to properly left align content.
Preserve this and only strip trailing whitespace from the logs. Also to
simplify the process of stripping whitespace consolidate it all to just
before we write the logs rather than earlier in the process.

Change-Id: I6ca957902a9ea4a5f0dfdddeda4bd398a81979d9
This commit is contained in:
Clark Boylan 2017-09-06 12:35:17 -07:00
parent b0e9fc711a
commit 3d4e466e33
2 changed files with 5 additions and 5 deletions

View File

@ -22,8 +22,8 @@
- name: Validate output - shell task
shell: |
egrep "^.*\| node1 \| link/loopback" job-output.txt
egrep "^.*\| node2 \| link/loopback" job-output.txt
egrep "^.*\| node1 \| link/loopback" job-output.txt
egrep "^.*\| node2 \| link/loopback" job-output.txt
- name: Validate output - loop with items
shell: |

View File

@ -122,6 +122,7 @@ class CallbackModule(default.CallbackModule):
self._logger = logging.getLogger('zuul.executor.ansible')
def _log(self, msg, ts=None, job=True, executor=False, debug=False):
msg = msg.rstrip()
if job:
now = ts or datetime.datetime.now()
self._logger.info("{now} | {msg}".format(now=now, msg=msg))
@ -154,7 +155,6 @@ class CallbackModule(default.CallbackModule):
pass
else:
ts, ln = line.split(' | ', 1)
ln = ln.strip()
self._log("%s | %s " % (host, ln), ts=ts)
@ -275,7 +275,7 @@ class CallbackModule(default.CallbackModule):
if is_localhost:
for line in stdout_lines:
hostname = self._get_hostname(result)
self._log("%s | %s " % (hostname, line.strip()))
self._log("%s | %s " % (hostname, line))
def v2_runner_on_failed(self, result, ignore_errors=False):
result_dict = dict(result._result)
@ -554,7 +554,7 @@ class CallbackModule(default.CallbackModule):
msg = result_dict['msg']
result_dict = None
if msg:
msg_lines = msg.strip().split('\n')
msg_lines = msg.rstrip().split('\n')
if len(msg_lines) > 1:
self._log("{host} | {status}:".format(
host=hostname, status=status))