Skip to content

Commit

Permalink
feat: log unhandled exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikBjare committed Aug 3, 2020
1 parent 548f4fc commit 6ba8f97
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions aw_core/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ def setup_logging(
_create_file_handler(name, testing=testing, log_json=log_file_json)
)

def excepthook(type_, value, traceback):
root_logger.exception("Unhandled exception", exc_info=(type_, value, traceback))
# call the default excepthook if log_stderr isn't true (otherwise it'll just get duplicated)
if not log_stderr:
sys.__excepthook__(type_, value, traceback)

sys.excepthook = excepthook


def _get_latest_log_files(name, testing=False) -> List[str]: # pragma: no cover
"""Returns a list with the paths of all available logfiles for `name` sorted by latest first."""
Expand Down

0 comments on commit 6ba8f97

Please sign in to comment.