Rosanswers logo

I tried to use ROSCONSOLE_FORMAT as shown in Console Output Formatting on rosconsole wiki.

I configured my .bashrc as shown below:

source /opt/ros/hydro/setup.bash 
source ~/myproject/devel/setup.bash
export ROS_HOSTNAME=localhost
export ROS_MASTER_URI=<removed_link>
export ROBOT=sim
export ROSCONSOLE_FORMAT='[${severity}] [${node}@${function}:${line}]: ${message}'

For C++ I get expected outputs. However for any python program, for example

#!/usr/bin/env python
# license removed for brevity
import rospy
from std_msgs.msg import String

def talker():
    # pub = rospy.Publisher('chatter', String, queue_size=10)
    rospy.init_node('talker', anonymous=True)
    r = rospy.Rate(1)  # 10hz
    while not rospy.is_shutdown():
        # str = "hello world %s" % rospy.get_time()
        rospy.loginfo("Hello World!")
        # pub.publish(str)

if __name__ == '__main__':
    except rospy.ROSInterruptException:

I get unformatted outputs like:

mjyc@ubuntu:~$ python test.py
[INFO] [WallTime: 1405812621.854884] Hello World!
[INFO] [WallTime: 1405812622.856649] Hello World!
[INFO] [WallTime: 1405812623.856340] Hello World!
[INFO] [WallTime: 1405812624.856789] Hello World!
[INFO] [WallTime: 1405812625.855262] Hello World!

Anybody has any clue?

I'm on Ubuntu 12.04 and using hydro.

Originally posted by Andrzej Pronobis on ROS Answers with karma: 43 on 2014-07-20

Post score: 3

Original comments

Comment by gvdhoorn on 2015-04-07:
FYI: ros_comm/pull/519 adds support for ROSCONSOLE_FORMAT to rospy. It's currently only merged into indigo-devel though.


1 Answer 1


Rosanswers logo

Hi Andrzej,

so rosconsole is purley a C++ logging related package. rospy's logging seems to be somewhat unrelated. In particular the logging with rospy tutorial makes no mention of such a configuration of the output.

The only mention of ROSCONSOLE_FORMAT in https://github.com/ros/ros_comm is in C++ code and the code that seems to implent the output formatting in rospy is also pretty clearly not configurable in such a way.

It's probably pretty straight forward to implement support for that environment variable also for rospy. The existence of this file suggests to me that you can configure rospy to use your custom stream handler without touching rospy code itself, but I'm sure PR's to improve rospy are welcome.

Cheers, Niko

Edit: Check out the python logging module extesive configuration capabilities here: https://docs.python.org/2/library/logging.config.html

Originally posted by demmeln with karma: 4306 on 2014-07-21

This answer was ACCEPTED on the original site

Post score: 3

Original comments

Comment by Andrzej Pronobis on 2014-07-22:
Thanks a lot Niko for a very informative answer!

Comment by m_jaeyoon_c on 2014-07-23:
Thank you!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.