From 9156413dbd17675be18fe1e162cc54b1bd1110fd Mon Sep 17 00:00:00 2001 From: Eric Holscher Date: Wed, 1 Jun 2022 15:21:49 -0700 Subject: [PATCH] Truncate output that we log from commands to 10 lines Make output nicer and add first/last 10 lines Log correct string --- readthedocs/doc_builder/environments.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/readthedocs/doc_builder/environments.py b/readthedocs/doc_builder/environments.py index d142f897a7d..96be8c18bbd 100644 --- a/readthedocs/doc_builder/environments.py +++ b/readthedocs/doc_builder/environments.py @@ -455,11 +455,16 @@ def run_command_class( if build_cmd.failed: if warn_only: - msg = 'Command {cmd} failed'.format(cmd=build_cmd.get_command()) + msg = "Command failed" + build_output = "" if build_cmd.output: - msg += ':\n{out}'.format(out=build_cmd.output) + build_output += "\n".join(build_cmd.output.split("\n")[10:]) + build_output += "\n ..Output Truncated.." + build_output += "\n".join(build_cmd.output.split("\n")[:10]) log.warning( msg, + command=build_cmd.get_command(), + output=build_output, project_slug=self.project.slug if self.project else '', version_slug=self.version.slug if self.version else '', )