Skip to content
This repository was archived by the owner on May 31, 2025. It is now read-only.

Added args and kwargs to rospy.log*#1289

Merged
dirk-thomas merged 3 commits intoros:melodic-develfrom
magazino:log-kwargs
Feb 10, 2020
Merged

Added args and kwargs to rospy.log*#1289
dirk-thomas merged 3 commits intoros:melodic-develfrom
magazino:log-kwargs

Conversation

@mgrrx
Copy link
Copy Markdown
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.

name = kwargs.get('logger_name')
if name:
rospy_logger = rospy_logger.getChild(name)
del kwargs['logger_name']
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

mgrrx commented Feb 7, 2020

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

@dirk-thomas
Copy link
Copy Markdown
Member

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

That is why I removed the label.

@dirk-thomas
Copy link
Copy Markdown
Member

@ros-pull-request-builder retest this please

@dirk-thomas
Copy link
Copy Markdown
Member

Thanks for the patch.

@dirk-thomas dirk-thomas merged commit ac47b7b into ros:melodic-devel Feb 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants