Bug 1531234 - Write JS test structured logs to main_raw.log instead of intermixing them in stdout r=ahal
☠☠ backed out by 86bf081288cd ☠ ☠
authorSteve Fink <sfink@mozilla.com>
Thu, 28 Feb 2019 17:46:30 +0000
changeset 519684 8fd728e30375435d190255e425ee1b78404d3e7e
parent 519683 aff1fa1030cedc7b16348132771b431f1a1d2c4a
child 519685 9e315d7f9e8af8eb6f0e167240d228c1a861f6d3
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersahal
bugs1531234
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1531234 - Write JS test structured logs to main_raw.log instead of intermixing them in stdout r=ahal Differential Revision: https://phabricator.services.mozilla.com/D21483
js/src/tests/lib/structuredlog.py
--- a/js/src/tests/lib/structuredlog.py
+++ b/js/src/tests/lib/structuredlog.py
@@ -1,34 +1,38 @@
 # produce mozlog-compatible log messages, following the spec at
 # https://mozbase.readthedocs.io/en/latest/mozlog.html
 
+from __future__ import print_function
+
 import json
 import os
 
 from time import time
 
 
 class TestLogger(object):
     def __init__(self, source, threadname='main'):
         self.template = {
             'source': source,
             'thread': threadname,
             'pid': os.getpid(),
         }
+        directory = os.environ.get("MOZ_UPLOAD_DIR", ".")
+        self.fh = open(os.path.join(directory, threadname + "_raw.log"), "a")
 
     def _record(self, **kwargs):
         record = self.template.copy()
         record.update(**kwargs)
         if 'time' not in record:
             record['time'] = time()
         return record
 
     def _log_obj(self, obj):
-        print(json.dumps(obj, sort_keys=True))
+        print(json.dumps(obj, sort_keys=True), file=self.fh)
 
     def _log(self, **kwargs):
         self._log_obj(self._record(**kwargs))
 
     def suite_start(self):
         self._log(action='suite_start', tests=[])
 
     def suite_end(self):