Bug 1372668 - [mozlog] Limit the size of data logged from error message when suite_start called multiple times, r=jgraham

We've seen a couple of enormous log files (200MB+). This largely happened due to a bug in the test harness that resulted
in suite_start being called over and over again. In each of these instances, mozlog logged something like:
log.error("Suite start called multiple times: {}".format(data))

The problem is that 'data' contained every single test id in the suite, which was *a lot*. Dumping all test ids in that
error message is not useful for debugging. This patch limits the size of the 'suite_start' data in the error message to
100 characters.

MozReview-Commit-ID: GnPizNrZ2QJ

--HG--
extra : rebase_source : 985d484544da9ea4cce445ce406fe085f86f112b
This commit is contained in:
Andrew Halberstadt 2017-06-14 11:20:39 -04:00
parent b659b49c15
commit aeecd3dc7c

View File

@ -254,8 +254,9 @@ class StructuredLogger(object):
def _ensure_suite_state(self, action, data):
if action == 'suite_start':
if self._state.suite_started:
# limit data to reduce unnecessary log bloat
self.error("Got second suite_start message before suite_end. " +
"Logged with data: {}".format(json.dumps(data)))
"Logged with data: {}".format(json.dumps(data)[:100]))
return False
self._state.suite_started = True
elif action == 'suite_end':