Skip to content

Logs from child loggers are not sent to /rosout #1694

@rasmusan

Description

@rasmusan

Bug report

Required Info:

  • Operating System:
    • Ubuntu 20.04
  • Installation type:
    • Binary
  • Version or commit hash:
    • galactic
  • DDS implementation:
    • Cyclone DDS
  • Client library (if applicable):
    • rclcpp

Steps to reproduce issue

Run this code:

#include "rclcpp/rclcpp.hpp"
#include "rcutils/logging_macros.h"

class MyNode : public rclcpp::Node
{
public:
  explicit MyNode(const std::string & node_name) : rclcpp::Node(node_name)
  {
    RCLCPP_INFO(get_logger(), "Node logger");
    RCLCPP_INFO(get_logger().get_child("child"), "Child logger");
  }
};

int main(int argc, char * argv[])
{
  rclcpp::init(argc, argv);
  rclcpp::executors::SingleThreadedExecutor exe;
  std::shared_ptr<MyNode> lc_node = std::make_shared<MyNode>("my_node");
  exe.add_node(lc_node->get_node_base_interface());
  exe.spin();

  rclcpp::shutdown();
  return 0;
}

Expected behavior

Terminal output:

1623765894.901377435 [INFO] [my_node::MyNode]: Node logger
1623765894.901569946 [INFO] [my_node.child::MyNode]: Child logger

File output to /home/user/.ros/log/logging_tester_81312_1623765894893:

1623765894.901377435 [INFO] [my_node::MyNode]: Node logger
1623765894.901569946 [INFO] [my_node.child::MyNode]: Child logger

Output on /rosout:

$ ros2 topic echo /rosout
stamp:
  sec: 1623765894
  nanosec: 901377435
level: 20
name: my_node
msg: Node logger
file: /home/user/ws/src/logging_tester/src/my_node.cpp
function: MyNode
line: 9
---
stamp:
  sec: 1623765894
  nanosec: 901377435
level: 20
name: my_node.child
msg: Child logger
file: /home/user/ws/src/logging_tester/src/my_node.cpp
function: MyNode
line: 10
---

Actual behavior

Output to terminal and to file is as expected. Output to /rosout only contains the top-level log, and not the child log:

$ ros2 topic echo /rosout
stamp:
  sec: 1623765894
  nanosec: 901377435
level: 20
name: my_node
msg: Node logger
file: /home/user/ws/src/logging_tester/src/my_node.cpp
function: MyNode
line: 9
---

Additional information

The child logs are omitted no matter if the child logger is stored as a member.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions