ROS 2 rclcpp + rcl - rolling  rolling-20536064
ROS 2 C++ Client Library with ROS Client Library
log_directory.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 <filesystem>
16 #include <string>
17 
18 #include "rcl_logging_interface/rcl_logging_interface.h"
19 
20 #include "rclcpp/exceptions.hpp"
21 #include "rclcpp/log_directory.hpp"
22 
23 namespace rclcpp
24 {
25 
26 std::filesystem::path
28 {
29  char * log_dir = NULL;
30  auto allocator = rcutils_get_default_allocator();
31  rcl_logging_ret_t ret = rcl_logging_get_logging_directory(allocator, &log_dir);
32  if (RCL_LOGGING_RET_OK != ret) {
33  rclcpp::exceptions::throw_from_rcl_error(ret);
34  }
35  std::string path{log_dir};
36  allocator.deallocate(log_dir, allocator.state);
37  return path;
38 }
39 
40 } // namespace rclcpp
Versions of rosidl_typesupport_cpp::get_message_type_support_handle that handle adapted types.
RCLCPP_PUBLIC std::filesystem::path get_log_directory()
Get the current logging directory.