ros_comm icon indicating copy to clipboard operation
ros_comm copied to clipboard

Add exception hook and log them on logerr

Open esahin90 opened this issue 2 years ago • 1 comments

properly log exception within threads on logerr

behavior before change:

process[test_node-1]: started with pid [21234]
Exception in thread Thread-4:
Traceback (most recent call last):
  File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/home/sahin/catkin_ws/install/lib/test_package/test.py", line 14, in run
    raise Exception('in thread')
Exception: in thread
[test_node-1] process has finished cleanly

behavior after change:

process[test_node-1]: started with pid [21059]
[/test_node ERROR 1642419799.922205]: Traceback (most recent call last):
  File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/home/sahin/catkin_ws/install/lib/test_package/test.py", line 14, in run
    raise Exception('in thread')
Exception: in thread

[test_node-1] process has finished cleanly

This change makes it easier for log analytics to group together tracebacks for prioritizing bugfixes

esahin90 avatar Jan 17 '22 10:01 esahin90

Modified the change a bit to also include the exception hook from sys.excepthook https://docs.python.org/3/library/sys.html#sys.excepthook

esahin90 avatar Feb 16 '22 12:02 esahin90