Skip to content

Commit bd7f1d4

Browse files
committed
Truncate the beggining of the commands' output
Instead trunctaing the last part of the command, we truncate the beggining of it. This allows to understand what's happening if the command fails (e.g. LaTeX step) with more context to be able to solve it.
1 parent e2d4c72 commit bd7f1d4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

readthedocs/builds/tasks.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,9 @@ def archive_builds_task(days=14, limit=200, include_cold=False, delete=False):
148148
if data:
149149
for cmd in data:
150150
if len(cmd['output']) > MAX_BUILD_COMMAND_SIZE:
151-
cmd['output'] = cmd['output'][:MAX_BUILD_COMMAND_SIZE]
152-
cmd['output'] += "\n\nCommand output too long. Truncated at 1MB."
153-
log.warning('Truncating build command for build %s', build.pk)
151+
cmd['output'] = cmd['output'][-MAX_BUILD_COMMAND_SIZE:]
152+
cmd['output'] = "... (truncated) ...\n\nCommand output too long. Truncated to last 1MB.\n\n" + cmd['output'] # noqa
153+
log.warning('Truncating build command for build. build=%s', build.pk)
154154
output = BytesIO()
155155
output.write(json.dumps(data).encode('utf8'))
156156
output.seek(0)

0 commit comments

Comments
 (0)