Bug 1255986 - [moztest] Safe-guard structured logging for exceptions from bad handlers. r=jgraham

Any exception which gets thrown by a log handler while test results are getting generated, should
not cause test harnesses to stop immediately. To achive that the exception details are written to
stderr and not propagated up the stack.

MozReview-Commit-ID: ChyYxApYSGx

--HG--
extra : rebase_source : 9fc3fe597061bedb1df2f5b8de1daa4bd127ea1e
This commit is contained in:
Henrik Skupin 2016-06-03 22:20:59 +02:00
Родитель 0b57c68c53
Коммит 3caa86c072
1 изменённых файлов: 7 добавлений и 1 удалений

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

@ -207,7 +207,13 @@ class StructuredLogger(object):
return
for handler in self.handlers:
handler(data)
try:
handler(data)
except Exception:
# Write the exception details directly to stderr because
# log() would call this method again which is currently locked.
print >> sys.__stderr__, '%s: Failure calling log handler:' % __name__
print >> sys.__stderr__, traceback.format_exc()
def _make_log_data(self, action, data):
all_data = {"action": action,