Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add --set-master-logger-level option for 'rosmaster' to output LOG_API #1180

Merged
merged 10 commits into from
Oct 17, 2017

Conversation

k-okada
Copy link
Contributor

@k-okada k-okada commented Oct 6, 2017

extended version of #1173

$ roscore --master-logger-level debug
$ tail -f ${HOME}/.ros/log/latest/master.log 

will output LOG_API messages

@@ -56,6 +56,9 @@ def _get_optparse():
parser.add_option("-t", "--timeout",
dest="timeout",
help="override the socket connection timeout (in seconds).", metavar="TIMEOUT")
parser.add_option("--set-master-logger-level",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The set of the options seems redundant to me. How about just --master-logger-level?

@@ -108,6 +112,14 @@ def rosmaster_main(argv=sys.argv, stdout=sys.stdout, env=os.environ):
import socket
socket.setdefaulttimeout(float(options.timeout))

if options.master_logger_level:
level = {'debug': logging.DEBUG, 'info': logging.INFO, 'warn': logging.WARN, 'error': logging.ERROR, 'fatal': logging.FATAL}
if options.master_logger_level in level.keys():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we ignore the case and do options.master_logger_level.lower() here?

@@ -108,6 +112,14 @@ def rosmaster_main(argv=sys.argv, stdout=sys.stdout, env=os.environ):
import socket
socket.setdefaulttimeout(float(options.timeout))

if options.master_logger_level:
level = {'debug': logging.DEBUG, 'info': logging.INFO, 'warn': logging.WARN, 'error': logging.ERROR, 'fatal': logging.FATAL}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the dict contains multiple elements I would suggest naming the variable levels.

logger.info("set rosmaster.master logger level '{}'".format(options.master_logger_level))
logging.getLogger("rosmaster.master").setLevel(level[options.master_logger_level])
else:
logger.error("--set-master-logger-level received unkonwn option '{}'".format(options.master_logger_level))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling: unkonwn

@k-okada
Copy link
Contributor Author

k-okada commented Oct 7, 2017

@dirk-thomas , thanks for comments. updated PR.

# catkin/fuerte: no longer use ROS_ROOT-relative executables, search path instead
master = type_
# zenmaster is deprecated and aliased to rosmaster
if type_ in [Master.ROSMASTER, Master.ZENMASTER]:
package = 'rosmaster'
args = [master, '--core', '-p', str(port), '-w', str(num_workers)]
args = [master, '--core', '-p', str(port), '-w', str(num_workers), '--master-logger-level', str(master_logger_level)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this potentially pass False?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct, will not pass argument when master_logger_level is False

@@ -152,7 +155,7 @@ def _init_runner(self):
raise RLException("pm is not initialized")
if self.server is None:
raise RLException("server is not initialized")
self.runner = roslaunch.launch.ROSLaunchRunner(self.run_id, self.config, server_uri=self.server.uri, pmon=self.pm, is_core=self.is_core, remote_runner=self.remote_runner, is_rostest=self.is_rostest, num_workers=self.num_workers, timeout=self.timeout)
self.runner = roslaunch.launch.ROSLaunchRunner(self.run_id, self.config, server_uri=self.server.uri, pmon=self.pm, is_core=self.is_core, remote_runner=self.remote_runner, is_rostest=self.is_rostest, num_workers=self.num_workers, timeout=self.timeout,master_logger_level=self.master_logger_level)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space after comma.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in new commit

@dirk-thomas
Copy link
Member

Thank you very much for the patch and iterating on it.

@dirk-thomas dirk-thomas merged commit cd7efd4 into ros:lunar-devel Oct 17, 2017
@k-okada k-okada deleted the add_debug_log_api_roscore branch January 21, 2018 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants