ROS 2 rclcpp + rcl - humble  humble
ROS 2 C++ Client Library with ROS Client Library
node_logging.cpp
1 // Copyright 2017 Open Source Robotics Foundation, Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include "rclcpp/node_interfaces/node_logging.hpp"
16 
18 
19 NodeLogging::NodeLogging(rclcpp::node_interfaces::NodeBaseInterface * node_base)
20 : node_base_(node_base)
21 {
22  logger_ = rclcpp::get_logger(this->get_logger_name());
23 }
24 
25 NodeLogging::~NodeLogging()
26 {
27 }
28 
31 {
32  return logger_;
33 }
34 
35 const char *
37 {
38  return rcl_node_get_logger_name(node_base_->get_rcl_node_handle());
39 }
Pure virtual interface class for the NodeBase part of the Node API.
virtual RCLCPP_PUBLIC rcl_node_t * get_rcl_node_handle()=0
Return the rcl_node_t node handle (non-const version).
Implementation of the NodeLogging part of the Node API.
RCLCPP_PUBLIC const char * get_logger_name() const override
Return the logger name associated with the node.
RCLCPP_PUBLIC rclcpp::Logger get_logger() const override
Return the logger of the node.
RCLCPP_PUBLIC Logger get_logger(const std::string &name)
Return a named logger.
Definition: logger.cpp:27
RCL_PUBLIC RCL_WARN_UNUSED const char * rcl_node_get_logger_name(const rcl_node_t *node)
Return the logger name of the node.
Definition: node.c:512