From a54ab0f29e7d34ca4590c134f0b4224655d8fe17 Mon Sep 17 00:00:00 2001 From: Steve Fink Date: Thu, 28 Feb 2019 17:46:30 +0000 Subject: [PATCH] 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 --HG-- extra : moz-landing-system : lando --- js/src/tests/lib/structuredlog.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/js/src/tests/lib/structuredlog.py b/js/src/tests/lib/structuredlog.py index eec46c0cbd0a..0a9104a3c1e9 100644 --- a/js/src/tests/lib/structuredlog.py +++ b/js/src/tests/lib/structuredlog.py @@ -1,6 +1,8 @@ # 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 @@ -14,6 +16,8 @@ class TestLogger(object): '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() @@ -23,7 +27,7 @@ class TestLogger(object): 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))