Skip to content

Commit

Permalink
added parameter to stop client libraries from generating topics list in
Browse files Browse the repository at this point in the history
log messages (#1241)
  • Loading branch information
trobertson-cpr authored and mikepurvis committed Nov 20, 2017
1 parent 7fa0a5c commit 7493c51
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions clients/roscpp/include/ros/rosout_appender.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class ROSCPP_DECL ROSOutAppender : public ros::console::LogAppender
boost::mutex queue_mutex_;
boost::condition_variable queue_condition_;
bool shutting_down_;
bool disable_topics_;

boost::thread publish_thread_;
};
Expand Down
10 changes: 9 additions & 1 deletion clients/roscpp/src/libros/rosout_appender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "ros/topic_manager.h"
#include "ros/advertise_options.h"
#include "ros/names.h"
#include "ros/param.h"

#include <rosgraph_msgs/Log.h>

Expand Down Expand Up @@ -102,7 +103,14 @@ void ROSOutAppender::log(::ros::console::Level level, const char* str, const cha
msg->file = file;
msg->function = function;
msg->line = line;
this_node::getAdvertisedTopics(msg->topics);

// check parameter server/cache for omit_topics flag
// the same parameter is checked in rosout.py for the same purpose
ros::param::getCached("/rosout_disable_topics_generation", disable_topics_);

if (!disable_topics_){
this_node::getAdvertisedTopics(msg->topics);
}

if (level == ::ros::console::levels::Fatal || level == ::ros::console::levels::Error)
{
Expand Down
15 changes: 14 additions & 1 deletion clients/rospy/src/rospy/impl/rosout.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,20 @@ def _rosout(level, msg, fname, line, func):
try:
_in_rosout = True
msg = str(msg)
topics = get_topic_manager().get_topics()

# check parameter server/cache for omit_topics flag
# the same parameter is checked in rosout_appender.cpp for the same purpose
# parameter accesses are cached automatically in python
if rospy.has_param("/rosout_disable_topics_generation"):
disable_topics_ = rospy.get_param("/rosout_disable_topics_generation")
else:
disable_topics_ = False

if not disable_topics_:
topics = get_topic_manager().get_topics()
else:
topics = ""

l = Log(level=level, name=str(rospy.names.get_caller_id()), msg=str(msg), topics=topics, file=fname, line=line, function=func)
l.header.stamp = Time.now()
_rosout_pub.publish(l)
Expand Down

0 comments on commit 7493c51

Please sign in to comment.