Open 130s opened 2 years ago
@asmodehn Would you mind reviewing as you worked on https://github.com/ros/ros_comm/issues/1029 where support for Py logging conf was enhanced?
I think changing the logging format and the name of the installed conf file are not acceptable changes for released ROS distros. Could you look for alternatives?
I think changing the logging format and the name of the installed conf file are not acceptable changes for released ROS distros. Could you look for alternatives?
That's fair. The current state of this PR changes the format so I agree it'd be frowned upon by existing users. That said, we should be able to customize the format in the same approach taken in this PR. I just haven't tried yet.
Issue aimed
As reported in https://github.com/ros/ros_comm/issues/1384#issue-319859166, logs that are logged by Python's
logging
stops printing afterrospy.init_node
call, which shouldn't happen IMO (i.e. non-rospy
loggers should be able to keep logging separately fromrospy
loggers).Solution approach
rospy
so that it does NOT disable existing loggers (even afterinit_node
is called).logging
module that lets us achieve what I want.rosgraph
at the time of writing (2022/05/17) by the human operator. It can be done e.g. by setting env var by the following command on the BASH terminal where therospy
node you care about the logging runs on (Ref. wiki.ros.org/rospy/Logging):Open questions.
.conf
file is replaced with.yaml
for the reason said above.rospy
usecases.cmake
via Catkin). I'm just not so sure just yet if that implementation is good to configure runtime environment.melodic
branch? Good question. I can easily open another PR for newer branches if requested. At least we should be able to continue discussion on this PR.Manual test steps and result
Run
roscore
on another terminal.Build
rosgraph
pkg with this change on another bash terminal.Run the test code. I ran
ipython3
, and copy-pasted the test code.Test code
``` import logging import rospy LOGGERNAME = "my-logger" #logging.basicConfig(level=logging.WARN) logger = logging.getLogger(LOGGERNAME) logger.warning("log-1: Do not forget to run roscore on another terminal") print(logger) rospy.loginfo("2: Since node is not initialized, this shouldn't be printed") rospy.init_node("whaterver") logger.warning(3) rospy.loginfo(4) logger = logging.getLogger(LOGGERNAME) logger.warning(5) logger.warning("genlog-6") rospy.loginfo("roslog-7") ```Test result
Without the change in this PR:
With the change in this PR. You see all the logging sequence from 1 (except sequence-2 that is meant to be NOT printed):