Comments (5)
Looking back at roslaunch from ROS 1:
There are two lists of handlers for logging messages (for stdout and stderr) that are invoked every time a log function is called.
The provided functions for calling the handlers responsible for printing and logging are:
Each of the "printlog" functions prints to the screen as well as logs to a file:
Pythons logging module is used for writing to a log file
An initial call to configure_logging sets the log file path to:
<ROS_LOG_DIR>/<UUID>/roslaunch-<hostname>-<PID>.log
Where,
<ROS_LOG_DIR>
is fromrospkg.get_log_dir()
and prioritized as one of:$ROS_LOG_DIR
$ROS_HOME/log
~/.ros/log
<UUID>
is based on the host hardware address, a random sequence number, and the current time. Generated with Pythonsuuid.uuid1()
function (source). This UUID represents the run ID (associated with the ROS master) and it's used by all nodes for finding the log directory.<hostname>
is fromsocket.gethostname()
.<PID>
is fromos.getpid()
.
Node processes through launch are started with subprocess.Popen()
, which is used to redirect stdout and stderr if a "log output" flag is set (ie. output="log"
in XML):
The format for the node process log files are:
<ROS_LOG_DIR>/<UUID>/<name>-<counter>-stdout.log
<ROS_LOG_DIR>/<UUID>/<name>-<counter>-stderr.log
Where,
<name>
is the node name.<counter>
is a incremented for each node launched to avoid potential name collisions:
Some other things worth noting:
- A processes stderr is never logged to a file. This feature has been disabled (never implemented?) in favor of always printing to the screen. There was an effort made for adding support for logging to both screen and a file (along with log rotation), but has not been completed (ros/ros_comm#551).
- It would be a nice feature to have stderr and stdout interleaved in a log file for debugging.
- There does not seem to be a single file that contains logs from all nodes; instead logs for each node are found in separate log files. The closest thing is the
rosout
aggregates output on the "/rosout" topic process into a log file, but this does not capture regular stdout/stderr.- Having output from multiple nodes in a single log, or timestamped in separate logs, seems valuable for debugging.
Regarding ROS 2 launch, there are the following questions (with proposed answers):
- How to capture a nodes stdout/stderr and direct to screen, a log file, or both?
- We can use OnProcessIO event handler for processing stdout and stderr.
- Callbacks can be directed to a new
LaunchLogging
API that can be configured to direct stdout and sterr to the screen, a file, or both. LaunchLogging
can encapsulate formatting and writing to log files and/or the screen.- Similar to ROS 1, we can use Pythons logging module for writing to a file.
- A feature to configure the output of 'nodes' independently would be nice, but lieu of #114 and to keep things simple for the first iteration we can constrain configuration to the 'process' level (e.g. nodes in a shared process will share a configuration).
- Callbacks can be directed to a new
- Output from
LaunchService
(or a futureLaunchServer
) should be directed to both the screen and a log. - The following info can be retreived from a
ProcessIO
event:- Node/process name.
- The output.
- Destination: screen, log, or both.
- File descriptor: stdout or stderr.
- We can use OnProcessIO event handler for processing stdout and stderr.
- How to organize log files?
- Log files can be saved to a configurable directory (
~/.ros/log
).- Can be configured via the
LaunchLogging
API.
- Can be configured via the
- Launch log files can follow the naming scheme:
~/.ros/log/<DATETIME>-roslaunch-<hostname>-<counter>.log
.<DATETIME>
can have the formYYYY-MM-DD-HH-MM-SS-UUUU
and be retrieved with Pythons datetime module. This is a possible improvement over ROS 1 by allowing the user to easily sort logs by date-time. Alternatively, a random UUID could be used in place of time, but this seems less meaningful (or in the case of ROS 1 launch logs could compromise privacy since it contains the computer's network address).<hostname>
of the machine is useful for identifying the logs source.<counter>
can break ties in case two log files happen to have the same name. Maybe microseconds are good enough, but it doesn't hurt to check if a log file already exists.
- Log files can be saved to a configurable directory (
Features such as log rotation, consolidation, and common logging methods (e.g. to "rosout" topic) in rcl and language client libraries can be considered separately, perhaps deserving a design document.
@wjwwood Let me know your thoughts and things I've overlooked.
from launch.
From a discussion offline,
- Add PID to the log file name and make
<counter>
optional (only if file already exists):~/.ros/log/<DATETIME>-roslaunch-<hostname>-<PID>-<counter>.log
- Include support for stripping color escape sequences when logging to a file.
from launch.
All standing PRs have been merged, though I cannot say #104 (comment) points are all addressed.
from launch.
I don't think the two points in #104 (comment) are addressed, but I don't think they're critical and could be captured in separate tickets.
from launch.
I think this is done. I'm not sure if there's support for stripping color escape sequences, but a separate ticket can be opened for that.
from launch.
Related Issues (20)
- Launch doesn't stop running nodes when exception thrown HOT 2
- Can't include [launch_testing_ament_cmake] in a launch only package HOT 1
- Bug when setting launch arguments of included descriptions HOT 1
- Requirement:Only start all nodes and then this ros2 launch process exit HOT 2
- `ExecuteProcess` with `shell=True` gets incorrect exit code from the executed process HOT 2
- Add an option to disable creating log files by the launch system HOT 1
- Unexpected YAML parsing with get_attr and List[Entity] type HOT 1
- pytest 8.1 incompatibility: TypeError: import_path() missing 1 required keyword-only argument: 'consider_namespace_packages' HOT 3
- Tests on Windows falsely positive reporting passed due to SIGINT handling HOT 1
- ThisLaunchFileDir throws error in debug mode
- Change ISSUE_TEMPLATE.md HOT 1
- Return Code not set on SIGINT HOT 3
- RegisterEventHandler: action_matcher must be an 'ExecuteProcess' instance or a callable HOT 2
- Request for Release in Iron HOT 2
- Feature request: run multiple tests in parallel with `colcon test` HOT 3
- Default port and address of 'foxglove_bridge_launch.xml' not met when launching HOT 1
- Parameterized `launch_pytest` tests don't close node log files HOT 5
- How to fix the crash caused by deleting the .ros/log folder during program execution HOT 1
- [Question] - How to configure sigterm_timeout/sigkill_timeout for a node HOT 1
- :farmer: TestROS2TopicUseSimTime.test_pub_times failing in Linux Coverage
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from launch.