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

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

Closed
wkentaro wants to merge 1 commit intoros:kinetic-develfrom
wkentaro:logging-named
Closed

[rospy] Logging function for rospy with node/func named msg#875
wkentaro wants to merge 1 commit intoros:kinetic-develfrom
wkentaro:logging-named

Conversation

@wkentaro
Copy link
Copy Markdown
Contributor

@wkentaro wkentaro 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

@tfoote
Copy link
Copy Markdown
Member

tfoote 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
Copy link
Copy Markdown
Contributor Author

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
Copy link
Copy Markdown
Member

tfoote 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
Copy link
Copy Markdown
Member

Can this be closed then?

@wkentaro
Copy link
Copy Markdown
Contributor Author

yes.
Moved to #877

@wkentaro wkentaro closed this Aug 30, 2016
@wkentaro wkentaro deleted the logging-named branch September 19, 2016 19:15
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 pushed a commit to ros/nodelet_core that referenced this pull request Sep 19, 2016
* 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 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