Class: ROS::Log
- Inherits:
-
Object
- Object
- ROS::Log
- Defined in:
- lib/ros/log.rb
Overview
Logging class for ROS
This class enable double logging: ROS Logging system and ruby log.
Constant Summary collapse
- ROSOUT_TOPIC =
topic name of rosout
'/rosout'
Instance Method Summary collapse
-
#initialize(node, output = $stdout) ⇒ Log
constructor
start publishing /rosout and make a ruby logger instance for local output.
-
#log(severity, message, file = '', function = '', line = 0) ⇒ Log
outputs log messages with level and informations which rosout needs.
Constructor Details
#initialize(node, output = $stdout) ⇒ Log
start publishing /rosout and make a ruby logger instance for local output
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/ros/log.rb', line 30 def initialize(node, output=$stdout) @node = node @rosout = @node.advertise(ROSOUT_TOPIC, Rosgraph_msgs::Log, :no_resolve=>true) @ruby_dict = {'FATAL'=>Logger::FATAL, 'ERROR'=>Logger::ERROR, 'WARN'=>Logger::WARN, 'INFO'=>Logger::INFO, 'DEBUG'=>Logger::DEBUG} @msg_dict = {'FATAL'=>::Rosgraph_msgs::Log::FATAL, 'ERROR'=>::Rosgraph_msgs::Log::ERROR, 'WARN'=>::Rosgraph_msgs::Log::WARN, 'INFO'=>::Rosgraph_msgs::Log::INFO, 'DEBUG'=>::Rosgraph_msgs::Log::DEBUG} @local_logger = Logger.new(output) end |
Instance Method Details
#log(severity, message, file = '', function = '', line = 0) ⇒ Log
outputs log messages with level and informations which rosout needs.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/ros/log.rb', line 56 def log(severity, , file='', function='', line=0) @local_logger.log(@ruby_dict[severity], , @node.node_name) msg = Rosgraph_msgs::Log.new msg.msg = msg.header.stamp = ::ROS::Time.now msg.header.frame_id = 'rosout' msg.level = @msg_dict[severity] msg.name = @node.node_name msg.file = file msg.function = function msg.line = line msg.topics = @node.get_published_topics @rosout.publish(msg) self end |