Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to disable creating log files by the launch system #761

Open
ksuszka opened this issue Feb 23, 2024 · 1 comment
Open

Add an option to disable creating log files by the launch system #761

ksuszka opened this issue Feb 23, 2024 · 1 comment

Comments

@ksuszka
Copy link

ksuszka commented Feb 23, 2024

Feature request

Add an option to disable creating log files by the launch system.

Feature description

We deploy a ROS application which uses the launch subsystem using docker containers. We try to follow well known industry guidelines like Heroku's 12-factor app https://12factor.net/logs. This guideline states that the application should not force creating log files but instead it should output log entries using standard streams. This makes a lot of sense, especially if you deploy the application to an embedded device with a flash storage that wears quickly with unnecessary writes.

At the moment is seems that there is no way to disable creating launch.log file as it is created unconditionally in the get_logger function of the launch system:

launch_log_file_handler = launch_config.get_log_file_handler()
.

Implementation considerations

@ksuszka
Copy link
Author

ksuszka commented Mar 1, 2024

Unfortunately, it seems that the launch system is only the tip of the iceberg. There are various parts of the ROS ecosystem that unconditionally create log files. For example, in theory there is a possibility to disable creating log files in rclcpp/rclpy by adding --disable-external-lib-logs argument to the init function, but there are places like ros2 service where you cannot add this argument, so every successful call to ros2 service creates a file on disk.

We were able to remove creation of most of the log files by adding custom extensions to the launch system:

  • the ros2launch.option.OptionExtension type extension which:
    • patches the launch.logging.launch_config object by replacing FileHandler with NullHanlder,
    • patches the launch.logging.launch_config object by changing _log_dir to /tmp to prevent creation of subfolder for launch logs
    • replaces launch_ros.ros_adapters.get_ros_adapter function adding --disable-external-lib-logs to ROSAdapter initialization
  • the launch_ros.actions.node.NodeActionExtension type extension which adds --disable-external-lib-logs argument to launched nodes

but it is more a workaround than a proper solution and it doesn't solve the ros2 service case.

At this moment I think that the simplest solution would be to add to rclc/rclcpp/rclpy support for handling an environment variable like RCUTILS_USE_EXTERNAL_LIB_LOGS which could be set globally in the environment. And similar thing would be needed in the launch subsystem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant