Skip to content

Commit 6ba8f97

Browse files
committed
feat: log unhandled exceptions
1 parent 548f4fc commit 6ba8f97

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

aw_core/log.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ def setup_logging(
3939
_create_file_handler(name, testing=testing, log_json=log_file_json)
4040
)
4141

42+
def excepthook(type_, value, traceback):
43+
root_logger.exception("Unhandled exception", exc_info=(type_, value, traceback))
44+
# call the default excepthook if log_stderr isn't true (otherwise it'll just get duplicated)
45+
if not log_stderr:
46+
sys.__excepthook__(type_, value, traceback)
47+
48+
sys.excepthook = excepthook
49+
4250

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

0 commit comments

Comments
 (0)