launcher: Limit copies of massive debug logs in markdown file

When debugging is activated, we could end up with log files ranging in the
multi-megabyte or even gigabyte range. Copying those is expensive from a cpu/io
point of view in addition to clobbering the storage.

Instead of always copying those files, check if they are smaller than 500kB. If
not, don't copy them and instead provide a link to their location.

Fixes #52

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-devtools/-/merge_requests/203>
This commit is contained in:
Edward Hervey 2020-06-03 09:32:32 +02:00 committed by Edward Hervey
parent 124153fe06
commit 2dd165b4ec

View file

@ -246,9 +246,16 @@ class Test(Loggable):
if not self.options.redirect_logs:
self.out.flush()
for logfile in self.extra_logfiles:
self.out.write('\n\n## %s:\n\n```\n%s\n```\n' % (
os.path.basename(logfile), self.get_extra_log_content(logfile))
)
# Only copy over extra logfile content if it's below a certain threshold
# Avoid copying gigabytes of data if a lot of debugging is activated
if os.path.getsize(logfile) < 500 * 1024:
self.out.write('\n\n## %s:\n\n```\n%s\n```\n' % (
os.path.basename(logfile), self.get_extra_log_content(logfile))
)
else:
self.out.write('\n\n## %s:\n\n**Log file too big.**\n %s\n\n Check file content directly\n\n' % (
os.path.basename(logfile), logfile)
)
if self.rr_logdir:
self.out.write('\n\n## rr trace:\n\n```\nrr replay %s/latest-trace\n```\n' % (