Skip to content

Commit d116d7b

Browse files
committed
add option to set output_format via environment variable
Signed-off-by: Marc Bestmann <[email protected]>
1 parent 8cfa723 commit d116d7b

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

launch/launch/actions/execute_local.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@
7474
from ..utilities.type_utils import normalize_typed_substitution
7575
from ..utilities.type_utils import perform_typed_substitution
7676

77+
DEFAULT_OUTPUT_FORMAT = '[{this.process_description.final_name}] {line}'
78+
7779

7880
class ExecuteLocal(Action):
7981
"""Action that begins executing a process on the local system and sets up event handlers."""
@@ -89,7 +91,7 @@ def __init__(
8991
'sigkill_timeout', default=5),
9092
emulate_tty: bool = False,
9193
output: SomeSubstitutionsType = 'log',
92-
output_format: Text = '[{this.process_description.final_name}] {line}',
94+
output_format: Text = DEFAULT_OUTPUT_FORMAT,
9395
cached_output: bool = False,
9496
log_cmd: bool = False,
9597
on_exit: Optional[Union[
@@ -199,7 +201,14 @@ def __init__(
199201
self.__output = normalize_to_list_of_substitutions(tmp_output)
200202
else:
201203
self.__output = tmp_output
202-
self.__output_format = output_format
204+
205+
# Check if an environment variable is set and use this as a default
206+
self.__output_format = os.environ.get(
207+
'LAUNCH_OUTPUT_FORMAT', output_format
208+
)
209+
# Setting it locally in the launch file still overwrites the default
210+
if output_format != DEFAULT_OUTPUT_FORMAT:
211+
self.__output_format = output_format
203212

204213
self.__log_cmd = log_cmd
205214
self.__cached_output = cached_output

0 commit comments

Comments
 (0)