Contents
ROS has it's own topic-based mechanism, called rosout for recording log messages from nodes. These log messages are human-readable string messages that convey the status of a node.
Viewing these statements in real-time is best done through the rxconsole GUI application.
Log Statements
roscpp uses the rosconsole package to provide its client-side API. That API takes the form of a number of ROS_ macros:
rosconsole provides four different types of logging statements, at 5 different verbosity levels, with both printf- and stream-style formatting.
Base
ROS_DEBUG(...)
ROS_DEBUG_STREAM(args)
The base versions output to a logger named "ros.<your_package_name>".
Named
ROS_DEBUG_NAMED(name, ...)
ROS_DEBUG_STREAM_NAMED(name, args)
This will output to a logger named "ros.<your_package_name>.test_only". More information about this is available in the configuration file section.
Conditional
ROS_DEBUG_COND(cond, ...)
ROS_DEBUG_STREAM_COND(cond, args)
Conditional Named
ROS_DEBUG_COND_NAMED(cond, name, ...)
ROS_DEBUG_STREAM_COND_NAMED(cond, name, args)
Once [1.1+]
ROS_DEBUG_ONCE(...)
ROS_DEBUG_STREAM_ONCE(args)
ROS_DEBUG_ONCE_NAMED(name, ...)
ROS_DEBUG_STREAM_ONCE_NAMED(name, args)
Throttle [1.1+]
ROS_DEBUG_THROTTLE(period, ...)
ROS_DEBUG_STREAM_THROTTLE(period, args)
ROS_DEBUG_THROTTLE_NAMED(period, name, ...)
ROS_DEBUG_STREAM_THROTTLE_NAMED(period, name, args)
Filter [1.1+]
ROS_DEBUG_FILTER(filter, ...)
ROS_DEBUG_STREAM_FILTER(filter, args)
ROS_DEBUG_FILTER_NAMED(filter, name, ...)
ROS_DEBUG_STREAM_FILTER_NAMED(filter, name, args)
Filtered output allows you to specify a user-defined filter that extends the ros::console::FilterBase class. Your filter must be a pointer type.
The five different verbosity levels are, in order:
- DEBUG
- INFO
- WARN
- ERROR
- FATAL
rosconsole lets you disable or enable verbosity levels for specific packages and named loggers. For more information on the specifics of rosconsole, please see the rosconsole page.
The default verbosity level is INFO, so DEBUG statements will not be seen by default.
Output
There are four potential places a log message may end up, depending on the verbosity level:
stdout
DEBUG and INFO messages arrive on stdout if they are enabled. Note that this may not be sent to the screen depending on the value of the roslaunch/XML/node output parameter.
stderr
WARN, ERROR and FATAL messages arrive on stderr if they are enabled.
Node log file
Everything enabled goes into the log file. Your node's log file will be in ~/.ros/log unless you override it with the ROS_HOME or ROS_LOG_DIR environment variables. If you are using roslaunch, you can use the roslaunch-logs command to tell you the location of the log directory.
/rosout topic
Everything enabled is sent to the /rosout topic. Note that until the node is fully started, messages will not be sent, so you may not see initial messages.
Here is a table summarizing the above:
|
Debug |
Info |
Warn |
Error |
Fatal |
stdout |
X |
X |
|
|
|
stderr |
|
|
X |
X |
X |
log file |
X |
X |
X |
X |
X |
/rosout |
X |
X |
X |
X |
X |
Also note that this table is different for rospy.
Setting Verbosity Levels
There are two ways of setting verbosity levels on a roscpp node. The first is through a configuration file which sets the verbosity level for every node in the system, the second is at runtime through the rxloggerlevel or rxconsole tools.
See the rosconsole documentation for details.






