logging for bureau exception traces

workspace
Brendan Howell 7 years ago
parent b31bd3fa84
commit 1ad025c043

@ -5,6 +5,7 @@ import json
import logging
import os.path
import subprocess
import sys
import tempfile
import textwrap
import threading
@ -115,6 +116,7 @@ class Bureau(object):
log_format = logging.Formatter('LOG ${levelname} $name: $message', style='$')
log_printer.setFormatter(log_format)
self.log.addHandler(log_printer)
sys.excepthook = self._log_exception
# setup a dir to store files and data
self.datadir = os.path.join(basepath, self.prefix)
@ -133,6 +135,10 @@ class Bureau(object):
self.log.debug("commands: ")
self.log.debug(str(self.commands))
def _log_exception(typ, value, tb):
self.log.error("CRASH TRACE: {0}".format(str(value)), exc_info=(typ, value, tb))
sys.__excepthook__(typ, value, tb)
def load_config(self):
"""
load (or reload) config data from file

Loading…
Cancel
Save