Skip to content

Commit 303a0e1

Browse files
authored
Chore/real time logging order (#261) (#266)
The current ROS logging is buffered. I.e. `openmower logs` show logs as buffered blocks but not in real-time as they occur. This PR changes the buffering to only 1 line so that log entries get shown when they occur. I tested with OMOSv2, but did not tested with OMOSv1. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Improved container startup logging configuration to ensure real-time visibility of application output. * Optimized environment setup with streamlined version information sourcing and unbuffered I/O settings. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent a610dd2 commit 303a0e1

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

docker/openmower_entrypoint.legacy.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ set -e
55
source "/opt/ros/$ROS_DISTRO/setup.bash"
66
source /opt/open_mower_ros/devel/setup.bash
77

8+
# setup om environment
9+
source /opt/open_mower_ros/version_info.env
810
source /config/mower_config.sh
11+
912
# If OM_V2 is truthy, set HARDWARE_PLATFORM=2 and new (yaml-based) config, else 1 and environment config
1013
if [[ "${OM_V2,,}" =~ ^(true|1|yes)$ ]]; then
1114
export HARDWARE_PLATFORM=2
@@ -22,6 +25,8 @@ source "$(rospack find open_mower)/params/hardware_specific/$MOWER/default_envir
2225
export RECORDINGS_PATH=$HOME
2326
export PARAMS_PATH=$HOME
2427

25-
source /opt/open_mower_ros/version_info.env
28+
# Ensure stdout and stderr are unbuffered to get logging in real time order
29+
export ROSCONSOLE_STDOUT_LINE_BUFFERED=1
30+
export PYTHONUNBUFFERED=1
2631

2732
exec -- "$@"

docker/openmower_entrypoint.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ set -e
44
# setup ros environment
55
source "/opt/ros/$ROS_DISTRO/setup.bash"
66
source /opt/open_mower_ros/devel/setup.bash
7+
8+
# setup om environment
79
source /opt/open_mower_ros/version_info.env
810

911
# OSv2 debugging get controlled via env var DEBUG and has the ROSCONSOLE_CONFIG_FILE embedded
@@ -20,4 +22,8 @@ case "${DEBUG:-0}" in
2022
esac
2123
shopt -u nocasematch || true
2224

25+
# Ensure stdout and stderr are unbuffered to get logging in real time order
26+
export ROSCONSOLE_STDOUT_LINE_BUFFERED=1
27+
export PYTHONUNBUFFERED=1
28+
2329
exec -- "$@"

0 commit comments

Comments
 (0)