Skip to content

Commit 087e199

Browse files
authored
feat(autoware_utils_logging): split package (#37)
* feat(autoware_utils_logging): split package Signed-off-by: Takagi, Isamu <isamu.takagi@tier4.jp> * add deprecated message Signed-off-by: Takagi, Isamu <isamu.takagi@tier4.jp> --------- Signed-off-by: Takagi, Isamu <isamu.takagi@tier4.jp>
1 parent 417b3cc commit 087e199

File tree

10 files changed

+213
-53
lines changed

10 files changed

+213
-53
lines changed

autoware_utils/README.md

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ The ROS module provides utilities for working with ROS messages and nodes:
3535

3636
- **`debug_publisher.hpp`**: A helper class for publishing debug messages with timestamps.
3737
- **`diagnostics_interface.hpp`**: An interface for publishing diagnostic messages.
38-
- **`logger_level_configure.hpp`**: Utility for configuring logger levels dynamically.
3938
- **`msg_covariance.hpp`**: Indices for accessing covariance matrices in ROS messages.
4039
- **`msg_operation.hpp`**: Overloaded operators for quaternion messages.
4140
- **`parameter.hpp`**: Simplifies parameter retrieval and declaration.
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2023 Tier IV, Inc.
1+
// Copyright 2025 The Autoware Contributors
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -12,57 +12,17 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
// =============== Note ===============
16-
// This is a util class implementation of the logger_config_component provided by ROS 2
17-
// https://github.com/ros2/demos/blob/humble/logging_demo/src/logger_config_component.cpp
18-
//
19-
// When ROS 2 officially supports the set_logger_level option in release version, this class can be
20-
// removed.
21-
// https://github.com/ros2/ros2/issues/1355
22-
23-
// =============== How to use ===============
24-
// ___In your_node.hpp___
25-
// #include "autoware/universe_utils/ros/logger_level_configure.hpp"
26-
// class YourNode : public rclcpp::Node {
27-
// ...
28-
//
29-
// // Define logger_configure as a node class member variable
30-
// std::unique_ptr<autoware::universe_utils::LoggerLevelConfigure> logger_configure_;
31-
// }
32-
//
33-
// ___In your_node.cpp___
34-
// YourNode::YourNode() {
35-
// ...
36-
//
37-
// // Set up logger_configure
38-
// logger_configure_ = std::make_unique<LoggerLevelConfigure>(this);
39-
// }
40-
4115
#ifndef AUTOWARE_UTILS__ROS__LOGGER_LEVEL_CONFIGURE_HPP_
4216
#define AUTOWARE_UTILS__ROS__LOGGER_LEVEL_CONFIGURE_HPP_
4317

44-
#include "logging_demo/srv/config_logger.hpp"
45-
46-
#include <rclcpp/rclcpp.hpp>
47-
48-
namespace autoware_utils
49-
{
50-
class LoggerLevelConfigure
51-
{
52-
private:
53-
using ConfigLogger = logging_demo::srv::ConfigLogger;
54-
55-
public:
56-
explicit LoggerLevelConfigure(rclcpp::Node * node);
18+
// NOLINTBEGIN(build/namespaces, whitespace/line_length)
19+
// clang-format off
5720

58-
private:
59-
rclcpp::Logger ros_logger_;
60-
rclcpp::Service<ConfigLogger>::SharedPtr srv_config_logger_;
21+
#pragma message("#include <autoware_utils/ros/logger_level_configure.hpp> is deprecated. Use #include <autoware_utils_logging/logger_level_configure.hpp> instead.")
22+
#include <autoware_utils_logging/logger_level_configure.hpp>
23+
namespace autoware_utils { using namespace autoware_utils_logging; }
6124

62-
void on_logger_config_service(
63-
const ConfigLogger::Request::SharedPtr request,
64-
const ConfigLogger::Response::SharedPtr response);
65-
};
25+
// clang-format on
26+
// NOLINTEND
6627

67-
} // namespace autoware_utils
6828
#endif // AUTOWARE_UTILS__ROS__LOGGER_LEVEL_CONFIGURE_HPP_

autoware_utils/package.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<depend>autoware_perception_msgs</depend>
2121
<depend>autoware_planning_msgs</depend>
2222
<depend>autoware_utils_geometry</depend>
23+
<depend>autoware_utils_logging</depend>
2324
<depend>autoware_utils_math</depend>
2425
<depend>autoware_utils_pcl</depend>
2526
<depend>autoware_utils_visualization</depend>
@@ -28,7 +29,6 @@
2829
<depend>diagnostic_msgs</depend>
2930
<depend>geometry_msgs</depend>
3031
<depend>libboost-system-dev</depend>
31-
<depend>logging_demo</depend>
3232
<depend>rclcpp</depend>
3333
<depend>tf2</depend>
3434
<depend>tf2_eigen</depend>

autoware_utils_logging/CMakeLists.txt

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
cmake_minimum_required(VERSION 3.14)
2+
project(autoware_utils_logging)
3+
4+
find_package(autoware_cmake REQUIRED)
5+
autoware_package()
6+
7+
ament_auto_add_library(${PROJECT_NAME} SHARED
8+
"src/logger_level_configure.cpp"
9+
)
10+
11+
if(BUILD_TESTING)
12+
ament_add_ros_isolated_gtest(test_${PROJECT_NAME}
13+
"test/main.cpp"
14+
"test/cases/logger_level_configure.cpp"
15+
)
16+
target_link_libraries(test_${PROJECT_NAME} ${PROJECT_NAME})
17+
endif()
18+
19+
ament_auto_package()

autoware_utils_logging/README.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# autoware_utils_logging
2+
3+
## Overview
4+
5+
The **autoware_utils** library is a comprehensive toolkit designed to facilitate the development of autonomous driving applications.
6+
This package provides essential utilities for logging.
7+
It is extensively used in the Autoware project to handle common tasks such as configuring logger levels.
8+
9+
## Design
10+
11+
- **`logger_level_configure.hpp`**: Utility for configuring logger levels dynamically.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// Copyright 2023 Tier IV, 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+
// =============== Note ===============
16+
// This is a util class implementation of the logger_config_component provided by ROS 2
17+
// https://github.com/ros2/demos/blob/humble/logging_demo/src/logger_config_component.cpp
18+
//
19+
// When ROS 2 officially supports the set_logger_level option in release version, this class can be
20+
// removed.
21+
// https://github.com/ros2/ros2/issues/1355
22+
23+
// =============== How to use ===============
24+
// ___In your_node.hpp___
25+
// #include "autoware/universe_utils/ros/logger_level_configure.hpp"
26+
// class YourNode : public rclcpp::Node {
27+
// ...
28+
//
29+
// // Define logger_configure as a node class member variable
30+
// std::unique_ptr<autoware::universe_utils::LoggerLevelConfigure> logger_configure_;
31+
// }
32+
//
33+
// ___In your_node.cpp___
34+
// YourNode::YourNode() {
35+
// ...
36+
//
37+
// // Set up logger_configure
38+
// logger_configure_ = std::make_unique<LoggerLevelConfigure>(this);
39+
// }
40+
41+
#ifndef AUTOWARE_UTILS_LOGGING__LOGGER_LEVEL_CONFIGURE_HPP_
42+
#define AUTOWARE_UTILS_LOGGING__LOGGER_LEVEL_CONFIGURE_HPP_
43+
44+
#include <logging_demo/srv/config_logger.hpp>
45+
#include <rclcpp/rclcpp.hpp>
46+
47+
namespace autoware_utils_logging
48+
{
49+
50+
class LoggerLevelConfigure
51+
{
52+
private:
53+
using ConfigLogger = logging_demo::srv::ConfigLogger;
54+
55+
public:
56+
explicit LoggerLevelConfigure(rclcpp::Node * node);
57+
58+
private:
59+
rclcpp::Logger ros_logger_;
60+
rclcpp::Service<ConfigLogger>::SharedPtr srv_config_logger_;
61+
62+
void on_logger_config_service(
63+
const ConfigLogger::Request::SharedPtr request,
64+
const ConfigLogger::Response::SharedPtr response);
65+
};
66+
67+
} // namespace autoware_utils_logging
68+
69+
#endif // AUTOWARE_UTILS_LOGGING__LOGGER_LEVEL_CONFIGURE_HPP_

autoware_utils_logging/package.xml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0"?>
2+
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
3+
<package format="3">
4+
<name>autoware_utils_logging</name>
5+
<version>1.1.0</version>
6+
<description>The autoware_utils_logging package</description>
7+
<maintainer email="egon.kang@autocore.ai">Jian Kang</maintainer>
8+
<maintainer email="ryohsuke.mitsudome@tier4.jp">Ryohsuke Mitsudome</maintainer>
9+
<maintainer email="esteve.fernandez@tier4.jp">Esteve Fernandez</maintainer>
10+
<maintainer email="yutaka.kondo@tier4.jp">Yutaka Kondo</maintainer>
11+
<maintainer email="isamu.takagi@tier4.jp">Takagi, Isamu</maintainer>
12+
<license>Apache License 2.0</license>
13+
14+
<buildtool_depend>ament_cmake_auto</buildtool_depend>
15+
<buildtool_depend>autoware_cmake</buildtool_depend>
16+
17+
<depend>logging_demo</depend>
18+
<depend>rclcpp</depend>
19+
20+
<test_depend>ament_cmake_ros</test_depend>
21+
<test_depend>ament_lint_auto</test_depend>
22+
<test_depend>autoware_lint_common</test_depend>
23+
24+
<export>
25+
<build_type>ament_cmake</build_type>
26+
</export>
27+
</package>

autoware_utils/src/ros/logger_level_configure.cpp autoware_utils_logging/src/logger_level_configure.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#include "autoware_utils/ros/logger_level_configure.hpp"
15+
#include "autoware_utils_logging/logger_level_configure.hpp"
1616

1717
#include <rcutils/logging.h>
1818

19-
namespace autoware_utils
19+
namespace autoware_utils_logging
2020
{
21+
2122
LoggerLevelConfigure::LoggerLevelConfigure(rclcpp::Node * node) : ros_logger_(node->get_logger())
2223
{
2324
using std::placeholders::_1;
@@ -58,4 +59,4 @@ void LoggerLevelConfigure::on_logger_config_service(
5859
return;
5960
}
6061

61-
} // namespace autoware_utils
62+
} // namespace autoware_utils_logging
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright 2025 The Autoware Contributors
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 "autoware_utils_logging/logger_level_configure.hpp"
16+
17+
#include <gtest/gtest.h>
18+
19+
#include <memory>
20+
21+
class LoggerLevelConfigureNode : public rclcpp::Node
22+
{
23+
public:
24+
using LoggerLevelConfigure = autoware_utils_logging::LoggerLevelConfigure;
25+
26+
LoggerLevelConfigureNode() : rclcpp::Node("__auto__")
27+
{
28+
logger_configure_ = std::make_unique<LoggerLevelConfigure>(this);
29+
}
30+
31+
private:
32+
std::unique_ptr<LoggerLevelConfigure> logger_configure_;
33+
};
34+
35+
TEST(TestLoggerLevelConfigure, Instantiation)
36+
{
37+
const auto node = std::make_shared<LoggerLevelConfigureNode>();
38+
}

autoware_utils_logging/test/main.cpp

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copyright 2025 The Autoware Contributors
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/rclcpp.hpp>
16+
17+
#include <gtest/gtest.h>
18+
19+
class RclcppEnvironment : public testing::Environment
20+
{
21+
public:
22+
RclcppEnvironment(int argc, char ** argv) : argc(argc), argv(argv) {}
23+
void SetUp() override { rclcpp::init(argc, argv); }
24+
void TearDown() override { rclcpp::shutdown(); }
25+
26+
private:
27+
int argc;
28+
char ** argv;
29+
};
30+
31+
int main(int argc, char ** argv)
32+
{
33+
testing::InitGoogleTest(&argc, argv);
34+
testing::AddGlobalTestEnvironment(new RclcppEnvironment(argc, argv));
35+
return RUN_ALL_TESTS();
36+
}

0 commit comments

Comments
 (0)