diff --git a/rclcpp/src/rclcpp/init_options.cpp b/rclcpp/src/rclcpp/init_options.cpp index cffa06bd11..85e7f71800 100644 --- a/rclcpp/src/rclcpp/init_options.cpp +++ b/rclcpp/src/rclcpp/init_options.cpp @@ -44,6 +44,7 @@ InitOptions::InitOptions(const InitOptions & other) : InitOptions(*other.get_rcl_init_options()) { shutdown_on_sigint = other.shutdown_on_sigint; + initialize_logging_ = other.initialize_logging_; } bool @@ -70,6 +71,7 @@ InitOptions::operator=(const InitOptions & other) rclcpp::exceptions::throw_from_rcl_error(ret, "failed to copy rcl init options"); } this->shutdown_on_sigint = other.shutdown_on_sigint; + this->initialize_logging_ = other.initialize_logging_; } return *this; } diff --git a/rclcpp/test/rclcpp/test_init_options.cpp b/rclcpp/test/rclcpp/test_init_options.cpp index 53b2b9402e..7b54413315 100644 --- a/rclcpp/test/rclcpp/test_init_options.cpp +++ b/rclcpp/test/rclcpp/test_init_options.cpp @@ -45,6 +45,23 @@ TEST(TestInitOptions, test_construction) { } } +TEST(TestInitOptions, test_initialize_logging) { + { + auto options = rclcpp::InitOptions(); + EXPECT_TRUE(options.auto_initialize_logging()); + } + + { + auto options = rclcpp::InitOptions().auto_initialize_logging(true); + EXPECT_TRUE(options.auto_initialize_logging()); + } + + { + auto options = rclcpp::InitOptions().auto_initialize_logging(false); + EXPECT_FALSE(options.auto_initialize_logging()); + } +} + TEST(TestInitOptions, test_domain_id) { rcl_allocator_t allocator = rcl_get_default_allocator(); auto options = rclcpp::InitOptions(allocator);