ros / ros_comm

ROS communications-related packages, including core client libraries (roscpp, rospy, roslisp) and graph introspection tools (rostopic, rosnode, rosservice, rosparam).
http://wiki.ros.org/ros_comm
747 stars 914 forks source link

Log format of service exception handler #2321

Open destroy314 opened 1 year ago

destroy314 commented 1 year ago

When an exception raised in callback function of a service ,this function will log it to rosout:

https://github.com/ros/ros_comm/blob/842f0f026924323f605495da0b80493f15f0bdce/clients/rospy/src/rospy/impl/tcpros_service.py#L581-L582

However the return value of traceback.format_exception() is a list which cause it's hard to read the traceback message:

[ERROR] [1680007708.746949]: Error processing request:['Traceback (most recent call last):\n', '  File "/opt/ros/melodic/lib/python2.7/dist-packages/rospy/impl/tcpros_service.py", line 633,in _handle_request\n    response = convert_return_to_response(self.handler(request), self.response_class)\n', ...

Can we use ''.join() or traceback.format_exc() like the code below to get a better format?

https://github.com/ros/ros_comm/blob/842f0f026924323f605495da0b80493f15f0bdce/clients/rospy/src/rospy/topics.py#L753