Skip to content

Commit e3bc644

Browse files
authored
Build environment: log stderr (#12539)
This could have been useful while debugging #12529.
1 parent 121796c commit e3bc644

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

readthedocs/doc_builder/environments.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@
3838
log = structlog.get_logger(__name__)
3939

4040

41+
def _truncate_output(output):
42+
if output is None:
43+
return ""
44+
output_lines = output.split("\n")
45+
if len(output_lines) <= 20:
46+
return output
47+
return "\n".join(output_lines[:10] + [" ..Output Truncated.. "] + output_lines[-10:])
48+
49+
4150
class BuildCommand(BuildCommandResultMixin):
4251
"""
4352
Wrap command execution for execution in build environments.
@@ -548,15 +557,11 @@ def run_command_class(
548557
if build_cmd.failed:
549558
if warn_only:
550559
msg = "Command failed"
551-
build_output = ""
552-
if build_cmd.output:
553-
build_output += "\n".join(build_cmd.output.split("\n")[:10])
554-
build_output += "\n ..Output Truncated.. \n"
555-
build_output += "\n".join(build_cmd.output.split("\n")[-10:])
556560
log.warning(
557561
msg,
558562
command=build_cmd.get_command(),
559-
output=build_output,
563+
output=_truncate_output(build_cmd.output),
564+
stderr=_truncate_output(build_cmd.error),
560565
exit_code=build_cmd.exit_code,
561566
project_slug=self.project.slug if self.project else "",
562567
version_slug=self.version.slug if self.version else "",

0 commit comments

Comments
 (0)