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

[rospy] Logging function for rospy with node/func named msg #875

Closed
wants to merge 1 commit into from

Conversation

Projects
None yet
3 participants
@wkentaro
Copy link
Contributor

commented Aug 24, 2016

Below line outputs below image:

#!/usr/bin/env python

import rospy

rospy.init_node('a')

rospy.loginfo_func_named('a')
rospy.logwarn_func_named('a')
rospy.logfatal_func_named('a')
rospy.logerr_func_named('a')

rospy.loginfo_node_named('a')
rospy.logwarn_node_named('a')
rospy.logfatal_node_named('a')
rospy.logerr_node_named('a')

rospy.loginfo_node_func_named('a')
rospy.logwarn_node_func_named('a')
rospy.logfatal_node_func_named('a')
rospy.logerr_node_func_named('a')

rospy.loginfo_func_named('%d', 1)
rospy.logwarn_func_named('%d', 1)
rospy.logfatal_func_named('%d', 1)
rospy.logerr_func_named('%d', 1)

rospy.loginfo_node_named('%d', 1)
rospy.logwarn_node_named('%d', 1)
rospy.logfatal_node_named('%d', 1)
rospy.logerr_node_named('%d', 1)

def main():
    rospy.loginfo_func_named('a')
    rospy.logwarn_func_named('a')
    rospy.loginfo_node_named('a')
    rospy.logwarn_node_named('a')
    rospy.loginfo_node_func_named('a')
    rospy.logwarn_node_func_named('a')
main()

class Test(object):
    def __init__(self):
        rospy.loginfo_func_named('a')
        rospy.logwarn_func_named('a')
        rospy.loginfo_node_named('a')
        rospy.logwarn_node_named('a')
        rospy.loginfo_node_func_named('a')
        rospy.logwarn_node_func_named('a')
Test()

screen shot 2016-08-25 at 12 06 56 am

@wkentaro wkentaro force-pushed the wkentaro:logging-named branch from 00cac60 to 408b13a Aug 24, 2016

@tfoote

This comment has been minimized.

Copy link
Member

commented Aug 24, 2016

This looks to be extending the API and most of the functionality is covered in the Console Ouput Formatting options for rosconsole without changing the API.

@wkentaro

This comment has been minimized.

Copy link
Contributor Author

commented Aug 25, 2016

Oh, i didn't know about it, and it works for functions, but not seems not for methods in class.
The behavior seems defined here:
https://github.com/ros/ros_comm/blob/kinetic-devel/tools/rosgraph/src/rosgraph/roslogging.py#L174
do you have any idea how to display the class name also?
Currently it only outputs [__init__] not [Test::__init__].

@tfoote

This comment has been minimized.

Copy link
Member

commented Aug 25, 2016

The available information comes from the LogRecord datatype

You'd need to add logic using the inspect module to do the class lookup: python2 example, python3 example

@dirk-thomas

This comment has been minimized.

Copy link
Member

commented Aug 29, 2016

Can this be closed then?

@wkentaro

This comment has been minimized.

Copy link
Contributor Author

commented Aug 30, 2016

yes.
Moved to #877

@wkentaro wkentaro closed this Aug 30, 2016

@wkentaro wkentaro deleted the wkentaro:logging-named branch Sep 19, 2016

wkentaro added a commit to wkentaro/nodelet_core that referenced this pull request Sep 19, 2016

wkentaro added a commit to wkentaro/nodelet_core that referenced this pull request Sep 19, 2016

mikaelarguedas added a commit to ros/nodelet_core that referenced this pull request Sep 19, 2016

Add NodeletLazy abstract class for lazy transport (#45)
* Add NodeletLazy abstract class for lazy transport

* Add test for NodeletLazy with checking its lazy-ness

* Fix ROS logging format supporting ros/ros_comm#875

* Fix ever_subscribed_ flag setting location

* Clearfy the comment describing advertise method

* Parameterize the duration to warn the no connection

User can disable this feature by setting -1 to the param.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.