Setting logging directory per Node in Foxy
Hi, is there a way to set up my logger, so that it outputs log files into different directories?
For example, let's say I have a my_node
node, and I would like for it to log it's contents to ./ros/logs/my_node/
like
auto logger = rclcpp::get_logger("my_node");
logger.set_logging_directory(path_to_logging_dir/my_node) // (i know this doesn't exist right now, it's just an example)
is there a way to access the logging internals to do that?
I know that spdlog
library has basic_file_sink
ROS2 uses spdlog
underneath, so maybe there is an access to it?
I've seen
https://answers.ros.org/question/3577... but this is per launch file, and I want to separate on my node level, via rclcpp. I have also seen
https://docs.ros.org/en/foxy/Tutorial..., but here the default variables only respond to the main ros directory.
Or is the encapsulation by launch file the correct way to do things?
I see an API for getting the log directory, but I don't see one for setting it. https://github.com/ros2/rcl_logging/b...
Maybe there's a way to set the directory in the file
rcl_logging_external_initialize()
? Even then I think logging affects the whole process, so if an API was added to rclcpp it may affect all nodes in the process.You could try splitting your nodes into individual launch files, and then make a "master" launch file that references the others. Is this something feasible for you to try?
After some thinking, I think doing this via launch file seems the cleanest solution for this case.