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

Added args and kwargs to rospy.log* #1289

Merged
merged 3 commits into from Feb 10, 2020
Merged

Conversation

mgrrx
Copy link
Contributor

@mgrrx mgrrx commented Jan 1, 2018

Implements #1222

I changed the signature of _base_logger so that e.g. a key named logger_level can be used for formatting msg.

if name:
rospy_logger = rospy_logger.getChild(name)
del kwargs['logger_name']
Copy link
Member

Choose a reason for hiding this comment

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

Instead of kwargs.get(...) and del kwargs[...] could this continue to call kwargs.pop(...) as it was before?

@mgrrx mgrrx changed the base branch from lunar-devel to melodic-devel September 21, 2018 19:17
@mgrrx mgrrx force-pushed the log-kwargs branch 2 times, most recently from 2aa6f73 to ba0df3f Compare September 21, 2018 19:24
@mgrrx
Copy link
Contributor Author

mgrrx commented Sep 21, 2018

Rebased against melodic-devel and changed what was commented.

This was referenced Sep 21, 2018
level = kwargs.pop('logger_level', None)
once = kwargs.pop('logger_once', False)
throttle_identical = kwargs.pop('logger_throttle_identical', False)
def _base_logger(msg, args, kwargs, throttle=None,
Copy link
Member

Choose a reason for hiding this comment

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

I don't see why args are kwargs can't continue to be passed as *args and **kwargs. What is the benefit wrapping them into a single parameter?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since the logger functions (logdebug, loginfo, ...) accept *args and **kwargs and _base_logger has additional optional arguments I wanted to clearly separate them. It's a somewhat artificial case but let's assume one would write the following code:

rospy.loginfo("foo", once=True, throttle=rospy.Duration(1.0), level='fatal')
This would make no sense at all but would break the logic in _base_logger.

For me it only makes sense to set change the logger_name when calling rospy.log*.

@larslue
Copy link
Contributor

larslue commented Sep 10, 2019

Any chance that this pull request will be merged? I stumbled over the limitations of rospy.log* recently and realized that they can be fixed by this PR. I know that it's not urgent to merge it, but one has to continue to build workarounds around rospy.log* to support all ways of logging. A common example would be the exc_info, i.e. rospy.logdebug(msg, exc_info=True) which is not supported at the moment.

@mgrrx
Copy link
Contributor Author

mgrrx commented Feb 7, 2020

@dirk-thomas which change is required here? I thought I addressed all issues

@dirk-thomas
Copy link
Member

which change is required here? I thought I addressed all issues

That is why I removed the label.

@dirk-thomas
Copy link
Member

@ros-pull-request-builder retest this please

@dirk-thomas
Copy link
Member

Thanks for the patch.

@dirk-thomas dirk-thomas merged commit ac47b7b into ros:melodic-devel Feb 10, 2020
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

3 participants