Split ansible output into its own sub logger

The ansible output on a busy system can be huge and create a problem
for the logging system. Thus move it into its own sub logger so it can
be stripped or split out via log config if needed without sacrificing
the other usefull logs from zuul.AnsibleJob.

Change-Id: I8fc34ea6af09df9bf36d029482a3265d35fecef6
This commit is contained in:
Tobias Henkel 2019-06-24 15:56:53 +02:00
parent 2029ac77ba
commit 6ad2bced95
No known key found for this signature in database
GPG Key ID: 03750DEC158E5FA2
1 changed files with 5 additions and 1 deletions

View File

@ -1968,6 +1968,10 @@ class AnsibleJob(object):
("Ansible timeout exceeded: %s" % timeout,))
watchdog.start()
try:
ansible_log = get_annotated_logger(
logging.getLogger("zuul.AnsibleJob.output"),
self.zuul_event_id, build=self.job.unique)
# Use manual idx instead of enumerate so that RESULT lines
# don't count towards BUFFER_LINES_FOR_SYNTAX
idx = 0
@ -1980,7 +1984,7 @@ class AnsibleJob(object):
if idx < BUFFER_LINES_FOR_SYNTAX:
syntax_buffer.append(line)
line = line[:1024].rstrip()
self.log.debug("Ansible output: %s" % (line,))
ansible_log.debug("Ansible output: %s" % (line,))
self.log.debug("Ansible output terminated")
cpu_times = self.proc.cpu_times()
self.log.debug("Ansible cpu times: user=%.2f, system=%.2f, "