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
This commit is contained in:
Steve Fink 2019-02-28 17:46:30 +00:00
Родитель 0c5a05c19a
Коммит a54ab0f29e
1 изменённых файлов: 5 добавлений и 1 удалений

Просмотреть файл

@ -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))